[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] trading days in a week - for Graham



PureBytes Links

Trading Reference Links




Hi Graham,
 
Thank you for your code.
 
I have ploted it but seems there are differences 
when I compare with the weekly chart. I think it is mainly because some of the 
weeks have holidays in between e.g. M T TH F.
 
Thanks
KK
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A href="" 
  title=gkavanagh@xxxxxxxxxxxxx>Graham 
  To: <A 
  href="" 
  title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx 
  Sent: Wednesday, April 23, 2003 7:17 
  PM
  Subject: RE: [amibroker] trading days in 
  a week
  
  
  <SPAN 
  >Not sure what you are actually 
  trying to find. But here is the code I have for weekly chart in daily window. 
  I only go from Monday to Friday, or if the Monday is non trading day then 
  Tuesday open is week open etc
  <SPAN 
  lang=EN-AU 
  ><A 
  href="">file://weekly chart to be placed in indicator window 
  with daily setting
  <SPAN 
  lang=EN-AU 
  > 
  <SPAN 
  lang=EN-AU 
  >firstday = 
  <SPAN lang=EN-AU 
  >ValueWhen<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >( <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Cum<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >)==<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >, <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >() );
  <SPAN 
  lang=EN-AU 
  >Lastday = 
  <SPAN lang=EN-AU 
  >LastValue<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >());
  <SPAN 
  lang=EN-AU 
  >Countweekends 
  = <SPAN lang=EN-AU 
  >IIf<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(firstday==<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >, (<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Cum<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >()<<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(),-<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >))), <FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >+ (<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Cum<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >()<<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(),-<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >))) );
  <SPAN 
  lang=EN-AU 
  >numweeks = 
  <SPAN lang=EN-AU 
  >LastValue<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(Countweekends);
  <SPAN 
  lang=EN-AU 
  > 
  <SPAN 
  lang=EN-AU 
  >numweek = 
  Countweekends;
  <SPAN 
  lang=EN-AU 
  > 
  <SPAN 
  lang=EN-AU 
  >firstbar = 
  <SPAN lang=EN-AU 
  >LastValue<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Cum<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >))-<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >LastValue<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(numweek);
  <SPAN 
  lang=EN-AU 
  >weekref = 
  <SPAN lang=EN-AU 
  >Min<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >0<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >, <FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >5<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >-lastday-<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >4<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >*( <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >LastValue<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Cum<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >)) - <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Cum<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >) ) );
  <SPAN 
  lang=EN-AU 
  > 
  <SPAN 
  lang=EN-AU 
  >wo = 
  <SPAN lang=EN-AU 
  >IIf<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >IsEmpty<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >( <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(),-<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >()) ), <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >ValueWhen<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >()==firstday,<FONT 
  color=red face="Courier New"><SPAN lang=EN-AU 
  >O<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >), <FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >ValueWhen<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >()==<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >1<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >,<FONT 
  color=red face="Courier New"><SPAN lang=EN-AU 
  >O<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  > ) );
  <SPAN 
  lang=EN-AU 
  >wh = 
  <SPAN lang=EN-AU 
  >HHV<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=red face="Courier New"><SPAN lang=EN-AU 
  >H<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >,<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Min<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(),<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >5<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >));
  <SPAN 
  lang=EN-AU 
  >wl = 
  <SPAN lang=EN-AU 
  >LLV<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=red face="Courier New"><SPAN lang=EN-AU 
  >L<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >,<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >Min<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(<FONT 
  color=blue face="Courier New"><SPAN lang=EN-AU 
  >DayOfWeek<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(),<FONT 
  color=fuchsia face="Courier New"><SPAN lang=EN-AU 
  >5<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >));
  <SPAN 
  lang=EN-AU 
  >wc = 
  <SPAN lang=EN-AU 
  >C<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >;
  <SPAN 
  lang=EN-AU 
  > 
  <SPAN 
  lang=EN-AU 
  >weeko 
  =<SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(wo,weekref);
  <SPAN 
  lang=EN-AU 
  >weekh = 
  <SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(wh,weekref);
  <SPAN 
  lang=EN-AU 
  >weekl = 
  <SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(wl,weekref);
  <SPAN 
  lang=EN-AU 
  >weekc = 
  <SPAN lang=EN-AU 
  >Ref<FONT 
  color=black face="Courier New"><SPAN lang=EN-AU 
  >(wc,weekref);
  <SPAN 
  > 
  
  <FONT color=teal face="Times New Roman" 
  size=3><SPAN 
  >Cheers,<FONT 
  color=teal size=3><SPAN 
  >Graham
  <FONT 
  color=#339966 face="Times New Roman" size=2><SPAN 
  ><A 
  href=""><SPAN 
  >http://groups.msn.com/ASXShareTrading
  <FONT 
  color=#339966 face="Times New Roman" size=2><SPAN 
  ><A 
  href=""><SPAN 
  >http://groups.msn.com/FMSAustralia
  <SPAN 
  >-----Original 
  Message-----From: kk2628 
  [mailto:kk2628@xxxxxxxxxxxxxxxx] <SPAN 
  >Sent: Wednesday, 23 April 2003 5:13 
  PMTo: 
  amibroker@xxxxxxxxxxxxxxx<SPAN 
  >Subject: [amibroker] trading days in a 
  week
  <FONT face="Times New Roman" 
  size=2> 
  
  <SPAN 
  >Hi,
  
  <FONT face="Times New Roman" 
  size=2> 
  
  <SPAN 
  >So far the following code works to 
  calc number of trading days in a week except the first week and the last 
  week of the ticker. I do not understand why tday still return 5 even though 
  last week only have 2 trading days (since the week is not over yet) ? Any help 
  is much appreciated.
  
  <FONT color=black face="Times New Roman" 
  size=1>dw=<FONT 
  color=blue size=1><SPAN 
  >DayOfWeek<FONT color=black 
  size=1>();
  <FONT color=black face="Times New Roman" 
  size=1>firsttday = 
  <SPAN 
  >IIf<FONT color=black 
  size=1>(<FONT 
  color=blue size=1><SPAN 
  >Cum<FONT color=black 
  size=1>(<FONT 
  color=fuchsia size=1><SPAN 
  >1<FONT color=black 
  size=1>)==<FONT 
  color=fuchsia size=1><SPAN 
  >1<FONT color=black 
  size=1>,<FONT 
  color=fuchsia size=1><SPAN 
  >1<FONT color=black 
  size=1>,dw < 
  <SPAN 
  >Ref<FONT color=black 
  size=1>( dw, -<FONT 
  color=fuchsia size=1><SPAN 
  >1<FONT color=black 
  size=1> ));
  <FONT color=black face="Times New Roman" 
  size=1>tday = <FONT 
  color=blue size=1><SPAN 
  >ValueWhen<FONT color=black 
  size=1>( firsttday, 
  <SPAN 
  >1<FONT color=black 
  size=1>+ <FONT 
  color=blue size=1><SPAN 
  >BarsSince<FONT color=black 
  size=1>(<FONT 
  color=blue size=1><SPAN 
  >Ref<FONT color=black 
  size=1><SPAN 
  >(firsttday,-<FONT 
  color=fuchsia size=1><SPAN 
  >1<FONT color=black 
  size=1>)),<FONT 
  color=fuchsia face="Courier New" size=1><SPAN 
  >0<FONT 
  color=black size=1>); 
  
  
  <SPAN 
  >Many 
thanks
  
  <SPAN 
  >KK 
  <FONT face="Times New Roman" 
  size=2><SPAN 
  ><FONT 
  face="Courier New">Send BUG REPORTS to bugs@xxxxxxxxxxxxx<FONT 
  face="Courier New"><FONT 
  face="Courier New">Send SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx<FONT 
  face="Courier New">-----------------------------------------<FONT 
  face="Courier New">Post AmiQuote-related messages ONLY to: 
  amiquote@xxxxxxxxxxxxxxx (Web 
  page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT 
  face="Courier New">--------------------------------------------<FONT 
  face="Courier New">Check group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to 
  the Yahoo! Terms of 
  Service. 
  Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor












Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.