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

[amibroker] DaysBetweenDates()



PureBytes Links

Trading Reference Links

I'm having trouble with calculating the number of days between the dates of
two conditions, either daily or intraday intervals.  I looked at the
DeDateTime.dll
These were planned functions, but I don't see them implemented.
GetDaysBetween() and GetTradeDaysBetween()

Also tried...

/* Days Between Dates v3 */

price = Close;
sig = MA(High,20);
Cond1 = Cross(price,sig);
Cond2 = Cross(sig,price);

startDay = LastValue( ValueWhen( Cond1 , 1 ) );
endDay = LastValue( ValueWhen( Cond2 , 1 ) );
Daysbetween = abs(endDay - startDay  );
Plot(Close,"Close",1,1);
Plot(sig,"sig",2,1);
Plot(Daysbetween ,"Daysbetween ",10,1 | styleOwnScale);

//////////////
Also Tried this and wasn't able to resolve it to what I am trying to do.

/* Days Between dates v2 */
SetBarsRequired(1000,0);
function GetDaysInRange()
{ fb = Status("firstbarinrange");
eb = Status("lastbarinrange");
startday = LastValue( ValueWhen( fb, DayOfYear() ) );
startyear = LastValue( ValueWhen( fb, Year() ) );
endDay = LastValue( ValueWhen( eb, DayOfYear() ) );
endYear = LastValue( ValueWhen( eb, Year() ) );
Days = 365 * ( endYear - startyear ) + endDay - StartDay;
return Days;
}""+GetDaysInRange();

//Title = "" + GetDaysInRange();
Plot(Close,"Close",1,1);
Plot(GetDaysInRange(),"GetDaysInRange()",1,1);

Any Suggestions?
Thanks in advance.

Mr Valley