Indicator sudenly plots arrows all over the chart, It occurs more frecuently in M1

 

Hi, please your help with this:


My indicators suddenly starts to plot the arrow marks all over the chart. The indicator fails more often in M1 timeframe, but it also happens in higher timeframes if i let it run long enough.

If i reset the indicator or recompile it, it re-deploys itself and all seems fine again.

I do not experience this with the indicators that MT4 has as standard, for example fractals, so i assume is my code.

Attached you can see an image of the indicator when it fails and after i reset it. I'm also attaching the code of the indicator.

Thank you very much!

Rodolfo. Indicator failed Indicator ok-reset MT4 Version

Files:
PB.mq4  10 kb
 
  1.       int max = rates_total - prev_calculated - lookback;

    After the first run max is always negative, nothing happens.

    Do your lookbacks correctly #9#14 & #19


  2.    if(tipo == "ST")
          STBuffer[index]=price;
       else
          HMBuffer[index]=price;
    You never initialize them to EMPTY_VALUE.
 
William Roeder #:
  1. After the first run max is always negative, nothing happens.

    Do your lookbacks correctly #9#14 & #19


  2. You never initialize them to EMPTY_VALUE.

Thx a lot. I will take a look at the posts to work it out.


Rodolfo.