The reason seems to be because I am expecting everything to be reset to their values on the previous bar on every call to OnBarUpdate(). This seems to be a bad assumption. So I ask for clarification: Any variables declared in the "variables" region, outside the scope of OnBarUpdate(), will have their values persist in each call to OnBarUpdate(), right? Does the same hold true for the latest DataSeries values set?
Is there some way to have my indicator variables reset to the state they were in at the close of the last bar, so that these values can be used for intraday calculations? Or do I have to declare everything as DataSeries and access myvalue[1] all the time? That seems terribly memory-inefficient, unless there's some way to create 2-bar DataSeries.
The only alternative I can think of is to maintain copies of all variables with their values from the previous bar, and whenever FirstTickOfBar() occurs, to update these copies. That gets kind of messy if I have a lot of variables, though.
-A
Comment