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

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



PureBytes Links

Trading Reference Links

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@xxxxxxxxxxx] 
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@xxxxxxxx]
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@xxxxxxxxxxx]
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@xxxxxxxx]
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@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/




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/






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/




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/ 



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/O10svD/Me7FAA/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/