int rates_zero=(int)MathMax(1,prev_calculated-1); for(int i=rates_zero; i<rates_total; i++)
You also need an extra variable instead of rates_total for the arrow buffers. Two 'for' functions, =0 to <rates_total for MA and =1 to <rates_total-2 for arrows.
P.S. You also don't need 'offset', you can set the arrow value equal to high/low and offset it in pixels like with Fractals indicator with +-PLOT_ARROW_SHIFT. It''s one of the new things in MT5 which isn't available in MT4.
You also need an extra variable instead of rates_total for the arrow buffers. Two 'for' functions, =0 to <rates_total for MA and =1 to <rates_total-2 for arrows.
P.S. You also don't need 'offset', you can set the arrow value equal to high/low and offset it in pixels like with Fractals indicator with +-PLOT_ARROW_SHIFT. It''s one of the new things in MT5 which isn't available in MT4.
You also need an extra variable instead of rates_total for the arrow buffers. Two 'for' functions, =0 to <rates_total for MA and =1 to <rates_total-2 for arrows.
Still can't figurt it out , would you please tell me more detail , and any article to learn all the concept of "OnCalculate" ?
Many many thanks !!
See How to do your lookbacks correctly.
@Alain Verleyen It was the wrong link.
This link might help:
https://www.mql5.com/en/docs/basis/function/events
You need to recalculate only the last bars' values that change with new ticks. And the last bar is rates_total-1, you can't have buffer[rates_total-1+3] (that's why the MA goes to the sky on your second screenshot).
Look at the values_to_copy calculation, understand those and you'll know what to write for your buffers.

- www.mql5.com
Now I figure out the PLOT_ARROW_SHIFT, and I study hard every article for coding what I need since last weekend , but unluckily it still now work .
@kypa can you tell me more about this ? ( what a dumb am I ...kypa:
You also need an extra variable instead of rates_total for the arrow buffers. Two 'for' functions, =0 to <rates_total for MA and =1 to <rates_total-2 for arrows.
Thanks again !! :D

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all ,
Im a new bit for MT5, and now I face a problem about the indicator redraw ...
I have a moving average and arrow in the chart, first run everything looks just fine(see attach #1)
but after cpuple minutes , the indicator redraw seems go wrong (see attach #2)
here is my code
Any help ?
Thank you in advance ! :D