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

[amibroker] Re: Calendar Dates vs Trading Dates



PureBytes Links

Trading Reference Links

  If you have ecxcel you could create a dummy ticker which contains 
the dates including leap years.

 e.g. to create  the date column of the dummy ticker write the date 

 01/01/1970 in a cell .

  Right click the cell, a thick black outline will souround the cell.
   place the cursor around  the bottom right corner above a small 
square node, until the cursor turns into a black cross,( without 
arrows on its ends).
   Right click and drag this down, it will create the dates  
including the leap years.

 create the other data arrays and import into ami.

  You could the reference these dates using the foreign function. 

 
  
 Peter.

  



--- In amibroker@xxxxxxxxxxxxxxx, "Bob Jagow" <bjagow@xxxx> wrote:
> I only promised to teach you to fish, Ken 8>)
> 
> Forgetting leapyears, the 30 days has Sept... lookup code would be
> ----
> DaysInMonth = dim = IIf(Month()==2,28,IIf((Month()==4 OR Month()==6 
OR Month()==9 OR Month()==11),30,31));
> ----
> Given the buy datenum , add the hold period and calculate the sell 
datenum using dim.
> ie, if holdP = 30 and bDate = 1030329; sDate = bDate + holdP = 
1030359 = 103459 +100 -59 +59%dim = 1030528;
> 
> But I'm not sure that datenum() is what you really want. I'd prefer 
ApplyStop(3,1,tradingDays), which would involve subtracting Sat
> and Sun.
> 
> Comes back, therefore, to Julian Day because jd%7 is dayofweek() 
and you could calc TradingDays by
> ---
> td = holdp;
> for ( i = jd; i < jd+holdP; i++)
> {
>  m = i%7;
>  if (m == 0 OR  m == 6) td--;
> }
> 
> Googling julian days gave lots of hits:
> ---
> http://www.hermetic.ch/cal_stud/jdn.htm
> The Julian day (jd) is computed from Gregorian day, month and year 
(d, m, y) as follows:
> jd = ( 1461 * ( y + 4800 + ( m - 14 ) / 12 ) ) / 4 +( 367 * ( m - 
2 - 12 *( ( m - 14 ) / 12 ) ) ) / 12
> -( 3 * ( ( y + 4900 + ( m - 14 ) / 12 ) / 100 ) ) / 4 + d - 32075;
> 
> or
> 
> http://scienceworld.wolfram.com/astronomy/JulianDate.html
> JD = 367*y - Int(7*(y + int((m+9)/12))/4 + int(275*m/9) +d 
+1721013.5
> 
> ---
> Haven't tried either; would recommend that you check which ever you 
choose against one of the web jd calculators.
> 
> Bob
> 
> 
> 
> 
> -----Original Message-----
> From: Ken Close [mailto:closeks@x...]
> Sent: Tuesday, April 29, 2003 4:26 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Calendar Dates vs Trading Dates
> 
> 
> Thanks Bob. I hope I get something more specific. I imagine there is
> some manipulation of the DateNum() function but I have not been 
able to
> figure it out.
> 
> Ken
> 
> -----Original Message-----
> From: Bob Jagow [mailto:bjagow@x...]
> Sent: Tuesday, April 29, 2003 4:34 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Calendar Dates vs Trading Dates
> 
> I don't believe AB has a clue re calendar vs. trading days; you 
need the
> difference in Julian days.
> If you don't want to use a JDay dll and only need to know, for 
example,
> when the .75% Fido commission expires, consider a 30 days
> has Sept.... lookup.
> 
> Bob
> 
> -----Original Message-----
> From: Ken Close [mailto:closeks@x...]
> Sent: Tuesday, April 29, 2003 1:10 PM
> To: AmiBroker List
> Subject: [amibroker] Calendar Dates vs Trading Dates
> 
> 
> Help....I want to count the number of calendar days since a buy or
> short...
> 
> I have read msg # 16104 about creating a For loop inside a Jscript, 
but
> frankly can not understand what it is advising.
> 
> Can someone show me a simple way to determine the number of calendar
> days that have elapsed?  Maybe the new For loop can help?
> 
> I want to code in a "close trade" flag if there are more than x 
number
> of calendar days since the trade was initiated.  Because of other
> aspects of the code, I do not want to (can not) use the dll time 
stop
> that is in the files area.
> 
> Any help would really be appreciated.
> 
> Ken
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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
> http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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
> http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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 
http://docs.yahoo.com/info/terms/


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading!
Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/cjB9SD/od7FAA/AG3JAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 http://docs.yahoo.com/info/terms/