Indicator data becoming corrupted

 

hi!

i have written a custom indicator which draws some additional curves onto the main chart window. the indicator works well for a while but after some time, for example, if i come back to the chart after a few hours, i find that the indicator lines have become corrupted: they reflect the wrong values. if i open up the indicator dialog via "Indicators List", double click on the name of the indicator then select "Okay" and "Close", the entire indicator is redrawn and the correct values are restored. i suspect that the problem may lie in the fact that i might be missing some ticks due to intermittent connectivity, but i assumed that this would be taken into account due to the fact that i check the number of counted bars and then calculate all those that have not been counted.

   int counted = IndicatorCounted();
   
   if (counted > 0) {
      counted--;
   }
   

the interesting thing is that the corruption is not confined only to the most recent bars but seems to extend over the entire history on the chart. it is almost as if some event is causing all of the data in the indicator buffer to be corrupted.

if anybody has any ideas as to why this is happening, i would really appreciate the input!

best regards, andrew.

 
That is not enough code to help you. :(
 
  1. Contradictory information on IndicatorCounted() - MQL4 forum the counted-- is unneeded.
  2. Post the rest of the code. The problem is with your loop and the code within. Remember, usually counted==0 and your loop will be from 0 to 0. Look for uninitialized variables within.
Reason: