I want to evaluate the latest historical bar, but using barstate.islastconfirmedhistory
does not work. The script runs once but never again.
so I tried other barstates …
if barstate.isnew
will not be reexecuted at closing of realtimebar. Its uncertain, when the code will be reexecuted – if ever.
So barstate.isrealtime
is the only condition, that will be executed at every closing of realtimebar, but not only then. The disadvantage of this variant is that it will be executed more than 30 times a minute. So I wonder, if pine-scripts knows the concept of a static variable where I could store the index of the last processed bar and reexecute the script only if the number has changed?