Anti-Repainting Safeguards
What repainting is, how Backtrex prevents it (closed candles, next-candle entry, future-reading conditions refused) and what it means for your results.
What is repainting?
Repainting happens when an indicator or strategy changes its past signals after the fact. A buy signal visible on the history did not exist, or not yet, at the moment it seems to have fired.
It is one of the most common sources of misleading backtests: the strategy looks great on history and disappoints live.
Common causes
The current candle
An indicator computed on a candle that is still open changes with every tick. A signal can appear mid-candle and vanish at the close. A backtest that reads the finished candle shows it as confirmed.
Lookahead bias
Some calculations look ahead. A pivot or a zigzag is only known several candles after it forms: using it on the candle itself means reading the future.
The higher timeframe
Reading the current H4 or D1 candle from an M15 chart means using a closing price that does not exist yet.
How Backtrex prevents it
Closed candles
Conditions are checked on closed candles. A condition on a higher timeframe only reads that timeframe's closed candles.
Entry on the next candle
When the conditions are met, the entry happens at the open of the next candle. That is what a trader can really do: decide at the close, enter right after.
A check on every condition
Every read goes through an anti-cheat check on the data. A condition that reads the future cannot be added:
- The AI first tries to repair it automatically
- If it cannot, the window shows the refused block with the explanation
- The add button stays disabled
Rephrase with what is known at decision time: "the previous day's high" rather than "the day's high".
What this means for you
When a trade appears in your backtest:
- Every condition that triggered it was known at the candle's close
- The entry happened at a price you could have obtained
- The Why this trade panel shows the candle where each condition held
Export does not change the rule
Exported scripts carry the same rules, but each platform has its own data and its own engine:
- Python: replayed on the last year, it must reproduce Backtrex's trades exactly, otherwise it is not delivered
- Pine Script and MQL5: generated, to validate in your platform. Results can differ with the price feed and the broker's settings.
See Export.
Common misconception
"Waiting for the close means missing a candle." No: live, you can only act on a signal once the candle has closed. A backtest that acts earlier shows you trades you could never have taken.