I can't figure out, while initializing a data series, how to get the value from the previous bar. It's easy enough to do in the main loop but then I can't chart the data series. For example, the code for an EMA would look something like:
CODE:
Please log in to see this code.
How can I do this?
Size:
Color:
Typically,
DataSeries myEMA = Close*0 is one of the possible ways to initialize a series before the main loop. Looks like actually you're not initializing but building some data series, and need the value from the previous bar.
To reference the value from the previous "bar", use one of the shift operators e.g. DataSeries>>1. (See
DataSeries Object in the QuickRef.) However, this should not work with myEMA because it is empty.
In this example, calling the "x" in the loop will get the value from the previous bar:
CODE:
Please log in to see this code.
If this is not what you want, please explain.
Size:
Color:
Not the most elegant thing in the world, but that will do it. Thanks.
Size:
Color: