Session first bar: Is there a way to find it?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1263
Joined: 23 Nov 2010
Has thanked: 717 times
Been thanked: 221 times

Session first bar: Is there a way to find it?

Postby arjfca » 19 Jul 2012

Hello

We have a function "SessionLastBar" that return True if the actual bar was the last bar of a day session. I don't see a function to return true if the actual bar was the first of the session

Is there one? Anyway to determine it? I did try

Code: Select all

If SessionLastBar[1] = True then  SessionFirstBar = True

It doesn't work. It return true when SessionLastBar = True

I understand that I could use an input value and select the starting time, but I would like my function to be universal in an GMT time.

Martin

User avatar
ABC
Posts: 516
Joined: 16 Dec 2006
Has thanked: 110 times
Been thanked: 290 times
Contact:

Re: Session first bar: Is there a way to find it?

Postby ABC » 19 Jul 2012

Martin,

the problem seems to be that you are trying to reference a reserved word back, this usually doesn't work and should be avoided.
Create a variable to store the boolean value for SessionLastBar into and use this variable to reference back to the previous bar. This will give the result you are looking for.

Code: Select all


MySessionLastBar = SessionLastBar;

If MySessionLastBar[1] = True then SessionFirstBar = True;


You also might want to set SessionFirstBar to false again, in case MySessionLastBar[1] = false.

Regards,
ABC
These users thanked the author ABC for the post (total 2):
arjfcaJoshM

arjfca
Posts: 1263
Joined: 23 Nov 2010
Has thanked: 717 times
Been thanked: 221 times

Re: Session first bar: Is there a way to find it?

Postby arjfca » 19 Jul 2012

Thank you Chris

Here is the working code

Code: Select all

//SessionFirstBar
//Return True if the Actual bar was the first bar of a session

Var:
SessionLastPeriod (False);

SessionFirstBar = False;
SessionLastPeriod = SessionLastBar;

If sessionLastPeriod[1]  = True then SessionFirstBar = True;

Print (Time_S, "    ", sessionFirstBar);

Martin
Montreal,Canada


Return to “MultiCharts”