I found a solution. The problem is that on right-click refresh Metatrader trigger an event Calculate (even handler OnCalculate) but with some weird input parameters for example prev_calculated is 0 and etc. Obviously it is a bug which needs to be fixed by MT team. I added these lines in the begging of OnCalculate and it works now.
if(calculated!=0 &&prev_calculated==0){ return(calculated); }
Evdokimov1917: prev_calculated is 0 and etc. Obviously it is a bug which
needs to be fixed by MT team. I added these lines in the begging of OnCalculate and it works now.
- Not a bug. You refreshed, old data has been updated and all bars need to be recalculated — just like the initial run. Therefor prev_calculated
must be zero.
- Fix your broken code. There is no need for your calculated variable, use the real prev_calculated.
- See How to do your lookbacks correctly.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi All,
I created a custom indicator which draws lines by ObjectCreate function. In general it works how it is expected. If i remove it from chart it remove all created objects. And in general did not have any issue. However after I make right-click refresh it stops working and all objects remain on the chart. I have a feeling that it restart indicator but without calling Deinit. Do you know exactly what is happening after restart? I do not know how to avoid this issue. Please advice.