Page 1 of 1

help ! Last Bar Time of a Session needed

Posted: May 08 2015
by sptrader
Is there a function that returns the "time" of the last bar of a session ?
I ran into an unusual situation where my session is 1730 to 2355 and my study expects 2355 to be the last bar in that session (before plotting) but no data came in during that last 5 minute interval, thus my study didn't plot...
If 2350 was the last 5 minute bar of the 1730-2355 session (instead of 2355), how can I have the code adjust for that ? (as easy as possible- I'm not a pro programmer)..

Re: help ! Last Bar Time of a Session needed

Posted: May 08 2015
by fbertram
Hi SpTrader,

here is a code snippet I use to detect the last bar in a trading session:

Code: Select all

if CalcTime(Time, BarInterval) > SessionEndTime(1, 1) then
Trigger.Last = true
else Trigger.Last = false;
The last bar will have a time stamp at the session end. Therefore, adding the bar interval to it, will lead to a time after the session end.


Hope this helps,
best regards, Felix

Re: help ! Last Bar Time of a Session needed

Posted: May 08 2015
by sptrader
Thanks, Sounds perfect, I'll give it a try !