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

[amibroker] Re: Calendar Dates vs Trading Dates a la 4.34 BETA



PureBytes Links

Trading Reference Links

 Bob i  created a fake ticker in excel which spans about 50 years,
 It contains the correct dates including weekends,
 but trying to count the days, including the weekends does not work 
in ami.
  I  reference the fake ticker to count days using the  foreign 
function  when a buy condition was true ( the buy cond is used on a 
normal ticker).

  even though the fake ticker includes weekends, I assumed using cum 
on this fake ticker when the buy cond on a normal ticker was true, 
would increment the count from 
e.g. if the cum value was 5 on a friday then i thought the cum value 
would be 8 on a monday.

   It seems to count the same as the actual ticker i am using the buy 
cond on.

  Do you know of any way to count the days on a ticker with weekend 
data, as i could email you the fake ticker in which the dates range 
from 1960 to 2010 
 

 Peter,(not the same peter below).







--- In amibroker@xxxxxxxxxxxxxxx, "Bob Jagow" <bjagow@xxxx> wrote:
> Therre was an unclosed paren, Peter.
> ----
> function HermeticJulian( d, m, y )
> {
> 	result = ( 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;
> 	
> 	return result;
> }
> function ScienceworldJulian( d, m, y )
> {
> 	result = 367 * y - int(7 * (y + int((m + 9) / 12)) / 4)
>  + int(275* m / 9) + d + 1721013.5;
> 	
> 	return result;
> }
> ---
> The two return different results and neither gives the correct 
dayofweek(), which is needed in order to calculate ApplyStop.
> The correct dayofweek() is given by -32076 and +1721015, 
respectively.
> 
> Bob 
> 
> -----Original Message-----
> From: bluesinvestor [mailto:investor@x...]
> Sent: Wednesday, April 30, 2003 7:27 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Calendar Dates vs Trading Dates a la 4.34 
BETA
> 
> 
> Using the new function ability of Amibroker I have tried the 
following:
> 
> function HermeticJulian( d, m, y )
> {
> 	result = ( 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;
> 	
> 	return result;
> }
> 
> /*function ScienceworldJulian( d, m, y )
> {
> 	result = 367 * y - int(7 * (y + int((m + 9) / 12)) / 4 + int
(275
> * m / 9) + d + 1721013.5;
> 	
> 	return result;
> }*/
> 
> Filter=C>0;
> AddColumn(HermeticJulian(Day(),Month(),Year()),"Hermetic");
> //AddColumn(ScienceWorldJulian(Day(),Month(),Year
()),"ScienceWorld");
> 
> While I was able to get the first formula to work, the second 
returned
> an error (although I am not sure why).
> 
> Regards,
> Peter
> 
> -----Original Message-----
> From: Bob Jagow [mailto:bjagow@x...] 
> Sent: Saturday, April 26, 2003 3:28 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Calendar Dates vs Trading Dates
> 
> 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/
> 
> 
> 
> 
> 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 ---------------------~-->
Make Money Online Auctions! Make $500.00 or We Will Give You Thirty Dollars for Trying!
http://us.click.yahoo.com/KXUxcA/fNtFAA/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/