Indicator: array gets wiped every Init...

 

Set out to make a super simple indicator, shouldn't take more than 15 mins I thought...Not this time!

Indicator: show spread history (as data comes in) as bars in a separate window.

Problem: all indicator bars are cleared then changing TF.

Looks like the custom (indicator)array that holds the accumulated data is cleared in Init. ?

I found no way around this, except maybe store spread data in file, and retrieve

from there to create bars...maybe not a bad idea to log spread to file, but for now I'd

like to just display it.

I thought arrays were persistent and data retained until program end ... Something I've missed here ?

 

On the same TF, the arrays are sort of persistent, ie it evaluates only the new bars (assuming you have used IndicatorCounted appropriately) while the rest of the array values remain unchanged.


As soon as you change TF, all array values have to be re-evaluated from the stored values in the history, ie High, Low, Open, Close etc but "Spread" is not one of them. So you have to store them somewhere yourself, and read them back to display. Synchronising the display with the candle bars is something your indicator will have to manage.

Reason: