detecting a session change  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
GTrader
Posts: 83
Joined: 30 Oct 2012
Has thanked: 24 times
Been thanked: 8 times

detecting a session change

Postby GTrader » 12 Aug 2014

how do you detect a session change? i.e. how do i know this bar is either the last bar in a session or the first bar of a session?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: detecting a session change

Postby Henry MultiСharts » 13 Aug 2014

Hello GTrader,

You need to compare the date/time of the bar with EndDay and EndTime members of SessionObject.

GTrader
Posts: 83
Joined: 30 Oct 2012
Has thanked: 24 times
Been thanked: 8 times

Re: detecting a session change

Postby GTrader » 13 Aug 2014

Hi Henry,
I can't find a use example of the session object or where the current session object resides. I see there is a collection of sessions in the Bars object but I'm not sure how to identify the current session.

I'm trying to create an indicator that resets on a session change. Maybe there is an example somewhere of something like this? I am basically trying to create 2 things:

a) Vwap that automatically resets on a session change (the current one requires a datetime input), and
b) A function that returns an adjusted price series that takes out session open gaps. This would be used as the basis for calculating gapless indicators.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: detecting a session change  [SOLVED]

Postby JoshM » 13 Aug 2014

i.e. how do i know this bar is either the last bar in a session or the first bar of a session?
`Bars.LastBarInSession` returns true if the current bar is the last bar of the session. And if this property returns false for the current bar, but was true for the previous bar, the current bar is the first bar of the session.
I can't find a use example of the session object or where the current session object resides. I see there is a collection of sessions in the Bars object but I'm not sure how to identify the current session.
See this topic for example, but do note that there is (or was, depending on your MC .NET version) a limitation (see here) which was changed in MC 9.0 beta 1.


Return to “MultiCharts .NET”