|
I had similar question about comparing DateTime
formatted values to determine the days between them.
I wanted to be able to tell if it had been
more than 30 days since I exited a stock before taking an entry
signal
in the same stock.
This is the elegant solution Marcin Gorznski
at Amibroker Support supplied.
All I did here was convert the 'dt' array in
Marcin's solution from DateTime() to DateNum().
dt = DateNum();
dy = DayOfYear() + 365 * Year(); fb = Status("rangefromdate");
eb = Status("rangetodate"); Days = LastValue(ValueWhen( dt == eb, dy ) -
ValueWhen( dt == fb, dy ));
Plot(days,"days",colorBlack,styleLine);
If you really are comparing the start/end dates of
a backtest be sure your 'to date' is not past the last day in the
data
or this won't work because the dt array stops at
the last bar.
The solution doesn't deal with leap years, but I
could live with the possibilty of missing a trade or two every 4 years so
I didn't attempt to add that.
Regards,
Bob Johnson
----- Original Message -----
__._,_.___ Please note that this group is for discussion between users only. To get support from AmiBroker please send an e-mail directly to SUPPORT {at} amibroker.com For other support material please check also: http://www.amibroker.com/support.html
SPONSORED LINKS
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___ |
- Re: [amibroker] DaysBetweenDates() Bob Johnson
