Retaining value of variable outside IF condition

My variable "bo" shows correct value at 9:17 but after that it shows "0", I want to retain the value of the variable for the day after it is set. Also, I don't want to use loops, is there a way to acheive it?


time = TimeNum()/100==0917;


Have a look at the ValueWhen() function. Something like this should work:

bankNiftyOpen = Foreign("BANKNIFTY", "O");
bo = ValueWhen(TimeNum()/100 == 0917, bankNiftyOpen);
1 Like

Division is not really needed.

bo = ValueWhen(TimeNum() == 91700, bankNiftyOpen);

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.