I am trying to save the high, low, open, close from the first 15 minute bar of the day. Here is a fragment of the code just showing preserving the open price. The code correctly captures the open for the first 15 minutes, but when the next bar begins, the value of firstbaropen goes to NaN. Please help!!! Ty. fyi. On my 15 min 5 day chart, the first bar is always bar number 131 so i could also have coded it as in 2nd example.
1st example
def na = Double.NaN;
def condition = if SecondsFromTime(0930) == 0 && SecondsTillTime(0930) == 0
then BarNumber()
else na;
def StartBar = condition;
def firstBarOpen = if BarNumber() == StartBar
then open
else firstBarOpen[1];
2nd example
input startbar = 131;
def firstbaropen = if barnumber() == startbar
then open
else firstbaropen[1];
1st example
def na = Double.NaN;
def condition = if SecondsFromTime(0930) == 0 && SecondsTillTime(0930) == 0
then BarNumber()
else na;
def StartBar = condition;
def firstBarOpen = if BarNumber() == StartBar
then open
else firstBarOpen[1];
2nd example
input startbar = 131;
def firstbaropen = if barnumber() == startbar
then open
else firstbaropen[1];
Last edited by a moderator: