I have written an indicator without taking care of the fact it could repaint. I've searched all around the forum but couldn't find how to make it non repainting. So below some code, the code supposed to be responsible of the repainting (bar calculation). How to make it non repainting ?
//---- calculations of the necessary amount of data to be copied
//---- and the 'limit' starting index for the bars recalculation loop
if(prev_calculated>rates_total || prev_calculated<=0)// checking for the first start of the indicator calculation
limit=rates_total-StartBars; // starting index for calculation of all bars
limit=rates_total-prev_calculated; // starting index for calculation of new bars
............ some code .............
//---- main loop of the indicator calculation
for(int bar=limit; bar>=0; bar--)
Hi admin, thanks for your good work. I'm trying to understand repainting and non repainting indicators and the referenced post https://www.mql5.com/en/forum/40874 is no longer available. Could someone please point me to the right direction? Thanks
Wow. Old post there !
Ok, repainting, redrawing. Attach the indicator to any chart, low timeframe for testing purpose, mark every signal, if after few time, the indicator signals aren't no longer where it was marked : it is redrawing.
It's not always for commercial purpose, I don't think so, nobody, no coders would trade with a redrawing one, comes a point, in your daily usage, you'll need it non redrawing.
All is about the candles counting, something like, count it once, count it wise - it's an old post, I just remind that it was about logic :).
(I unfav the post). Hope it helps.
repainting is mostly occur on.
..and plus you have to look back (shift bar back). the greater the shift, the worst it repaint.most of the code are necessary (for the sake of coding), depend on which customs indicator are you using.
I start using counting forward rules in my coding example.it make almost no repaint (except for current non closing bar).
Hope it help.