The MT4 repainting problem gets a lot of coverage. MT5 traders ask the same question in a slightly different form: does the prev_calculated guard actually prevent an MT5 indicator from repainting, and how do I confirm it myself?
Short answer: prev_calculated is a tool, not a guarantee. Whether an indicator uses it correctly is a code decision, not a platform one. The test to verify it is the same screenshot comparison you would run on MT4 β with a few MT5-specific details worth understanding.
Key Findings
- MT5 has a built-in non-repaint mechanism: The
prev_calculatedparameter inOnCalculate()lets developers skip recalculating already-closed bars. MT4 has no equivalent β that guard must be coded manually. - The mechanism is only as good as the code: A developer who ignores
prev_calculatedand processes all bars on every tick produces an MT5 indicator that repaints just as badly as a poorly written MT4 indicator. - Five-minute screenshot test still applies: Load the indicator, record signals on closed bars, wait for new bars, compare. Any movement is repainting.
- Strategy Tester visual mode is definitive: Step through historical bars one at a time to see exactly what the indicator showed at each moment β matches or discrepancies are immediately visible.
How MT5’s indicator engine differs from MT4
MetaTrader 4 runs the indicator’s start() function on every incoming tick and recalculates all visible bars. There is no built-in way to know which bars were already processed. A developer who wants to prevent repainting must build that logic themselves β typically by checking whether a new bar has opened before doing any calculation.
MT5 changed the calculation model. The OnCalculate() function receives a prev_calculated integer: the number of bars processed in the last call. If prev_calculated equals rates_total (the total bars available), nothing new has printed and the indicator should skip recalculation entirely or process only the current bar. MetaQuotes documented this parameter in the MQL5 Reference as the primary mechanism for avoiding redundant and retroactive calculations (MQL5 Language Reference, Custom Indicators, MetaQuotes Software Corp., 2010βpresent).
That design makes it straightforward for a careful developer to write an indicator whose logic never revisits a closed bar. The problem is that nothing enforces it. If a developer receives prev_calculated as a parameter and then recalculates from bar zero anyway, the built-in tool achieves nothing.
How to install a custom indicator in MT5
MT5 uses .ex5 (compiled) or .mq5 (source) files in MQL5/Indicators/ rather than the MQL4/Indicators/ folder you may know from MT4.
- In MT5, open the MetaEditor from the toolbar or press F4. From the MetaEditor, choose File β Open Data Folder. This opens the root data directory for your terminal instance.
- Navigate to
MQL5/Indicators/. Copy your.ex5file into that folder. - Back in MT5’s Navigator panel (Ctrl+D), right-click “Indicators” and select Refresh.
- Find the indicator under “Custom Indicators”. Drag it onto a chart, or double-click to open the parameter dialog.
After the indicator loads, watch where it draws signals. An indicator that places output only on the far-right forming candle is not necessarily clean β it may calculate on the live bar and shift its signal every tick, mimicking non-repainting behaviour without delivering it.
How to test for repainting in MT5
The test is the same as MT4. Load the indicator on a chart with at least 30-50 closed bars. Take a screenshot of every visible signal. Wait for five to ten new bars to form. Compare the current chart to your screenshot. Any signal that changed position, colour, or disappeared is repainting.
MT5’s Strategy Tester visual mode accelerates this. Press Ctrl+R. Select an EA that uses the indicator or a simple wrapper script. Enable “Visual mode” and choose a historical date range. Step through bar by bar using the speed slider. Note each signal as it appears. When you reach the end, compare your notes to the final chart state.
| Feature | Repainting MT5 indicator | Non-repaint MT5 indicator |
|---|---|---|
| Signal at bar close | May shift on next tick | Locked to that bar permanently |
| Strategy Tester vs live chart | Signals differ | Signals match |
prev_calculated usage | Ignored or bypassed | Used to skip closed bars |
| Backtesting reliability | Misleading β hindsight trades | Accurate β matches live view |
| Demo forward test | Inconsistent signals | Consistent with historical view |
prev_calculated usageRelicusRoad Pro
Have you been trading for a while but have never made consistent profits or are you new to FOREX trading and want to get a head start? Try RelicusRoad and you'll never look back.
Get RelicusRoad ProDoes prev_calculated actually prevent repainting?
Only when used correctly. The standard correct pattern stores prev_calculated - 1 as the loop start index and iterates only from that point forward, leaving all prior bars untouched. A developer who resets that index to zero on every call β recalculating from the beginning of history β produces a repainting indicator even with prev_calculated present in the function signature.
The distinction is invisible from the indicator’s output alone. You cannot tell from looking at a chart whether prev_calculated was used correctly. The screenshot test is how you find out. There is no shortcut.
A separate pattern to watch for in MT5: some indicators use the iCustom() function to call another indicator’s buffers. If the called indicator repaints, the output of the wrapper repaints too, even if the wrapper’s own code is clean. Testing the final output β not just the top-level file β is what matters.
How RelicusRoad Pro handles this in MT5
RelicusRoad Pro
uses prev_calculated in its MT5 build to skip closed bars in every entry signal calculation. The Dynamic Reversal arrows and entry signals calculate at bar close and do not process prior bars on subsequent ticks.
To confirm this yourself, run the Strategy Tester visual mode on a historical date range and record each signal as it appears. Compare that record to the final chart. The output matches because each signal calculates once, at bar close, and is never overwritten.
The Road Levels and Signal Cloud overlays do update dynamically as price evolves. Those are support, resistance, and trend context layers β not entry arrows. The documentation distinguishes the two explicitly, and neither update should be confused with entry-signal repainting.
For a broader view of what repainting is and how it manifests across platforms, the non-repaint forex indicator guide covers the general mechanics, and the MT4 installation guide addresses the MT4-specific architecture in more detail.
Frequently asked questions
How do I verify a non-repaint indicator in MT5? Load the indicator on a chart with at least 30-50 closed bars. Screenshot or note every signal position. Wait for 5-10 new bars to form, then compare. Any signal that moved, changed colour, or disappeared is repainting. MT5’s Strategy Tester in visual mode gives the same result faster.
How does MT5’s prev_calculated parameter prevent repainting?
In MQL5, OnCalculate() receives prev_calculated β the number of bars processed in the previous call. A well-written indicator uses this to start calculation only from the newest unprocessed bar, leaving closed bars untouched. That is the core non-repaint mechanism.
Is MT5 better than MT4 for non-repaint indicators? MT5 gives developers better built-in tools to prevent repainting, but those tools only work when used correctly. A badly written MT5 indicator can still repaint. The verification test applies equally to both platforms.
Can MT5’s multi-threading cause indicator repainting? Custom indicators run on the main thread and receive tick data sequentially. Multi-threading is not the cause of repainting; the cause is always how the indicator writes to its buffers relative to bar close.
Does RelicusRoad Pro’s MT5 version repaint its entry signals? RelicusRoad Pro calculates entry signals at bar close on MT5 and locks them permanently. The Strategy Tester output matches the live chart. Dynamic context layers update as price evolves β that is by design and is not entry-signal repainting.
If an indicator looks perfect in backtesting but produces inconsistent results in a demo, the screenshot test takes five minutes and tells you exactly what is happening. The prev_calculated mechanism was built to solve this problem β the only question is whether the developer used it.