A new 20-day moving average will keep appearing during the test

 

In the test, the 20-day moving average will be refreshed continuously.   I have repeatedly debugged it and cannot find the reason.

Who has encountered this situation?


1
 

You are probably creating an Indicator handle in OnTick(), thus replicating the indicator, instead of only creating a handle once in OnInit().

That is probably why in your Data Window on the left there are so many MA(20) indicator outputs.

EDIT: Did you perhaps migrate your EA into MQL5 from an original MQL4 EA? If so, then you are converting it incorrectly.

 
Fernando Carreiro #:

You are probably creating an Indicator handle in OnTick(), thus replicating the indicator, instead of only creating a handle once in OnInit().

That is probably why in your Data Window on the left there are so many MA(20) indicator outputs.

EDIT: Did you perhaps migrate your EA into MQL5 from an original MQL4 EA? If so, then you are converting it incorrectly.

Thank you for your kindness !

I used the Indicator handle by shift,and in test the IndicatorRelease can't work.

I change the shift in CopyBuffer,the problem is solved.

Reason: