Question about ImaOnArray()

 

Is it possible to use regular arrays to accumulate price values so the array can then be used in ImaOnArray() or should drawing buffers always be used for this ?

 
 
WHRoeder:
ArraySetAsSeries


I tried that but when I used those arrays in ImaOnArray() the resulting lines were created correctly on chart history but on the live prices the lines deviated a lot from the expected positions, when I refresh the chart by either recompiling or bringing up the property box, the parts of the lines created from live prices are then redrawn in their correct positions. I changed the code to use drawing buffers instead of arrays and the problem was fixed.

I would still like to learn the correct way to use arrays instead of buffers for this mainly for the purpose of not wasting buffers that could be used for something else, I am wondering if the problem was caused because regular arrays do not reindex at the beginning of a new bar so maybe I need to loop through the array to move each value up one position at the beginning of each new bar ? If that is so would I have to do that while ArraySetAsSeries() is false and then set it to true before the ImaOnArray() loop ? or should ArraySetAsSeries() be true the whole time ?

Reason: