help ! Last Bar Time of a Session needed

Questions about MultiCharts and user contributed studies.
sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

help ! Last Bar Time of a Session needed

Postby sptrader » 08 May 2015

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)..

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 76 times
Contact:

Re: help ! Last Bar Time of a Session needed

Postby fbertram » 08 May 2015

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

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: help ! Last Bar Time of a Session needed

Postby sptrader » 08 May 2015

Thanks, Sounds perfect, I'll give it a try !


Return to “MultiCharts”