Multi timeframe filter in my EA and the repainting bug that fooled my backtest
Posted: Thu Oct 08, 2026 12:18 pm
Multi timeframe filter in my EA and the repainting bug that fooled my backtest
I added a higher timeframe filter to my M5 EA, using an M15 moving average to decide the direction. The backtest improved a lot, which should have made me suspicious. It turned out I'd made a classic mistake.
When the EA read the M15 value on the current bar, it was reading a value that wasn't final yet. In the tester, depending on how it's set up, that could include information from the future within the bar. The M15 candle was still forming, but the test was using values that only exist after it closed. Live, the EA only sees what's actually available at that moment, so the results didn't match.
The fix was to read the M15 values from the last closed bar, not the current one. That means the filter reacts one bar later, but it's what actually happens in real time. After that change, the backtest improvement mostly disappeared, which told me it wasn't real.
Whenever a result looks too good after a small change, I go looking for a mistake like this before I celebrate. Using only closed bar data for anything that comes from another timeframe is a rule I follow now.
I added a higher timeframe filter to my M5 EA, using an M15 moving average to decide the direction. The backtest improved a lot, which should have made me suspicious. It turned out I'd made a classic mistake.
When the EA read the M15 value on the current bar, it was reading a value that wasn't final yet. In the tester, depending on how it's set up, that could include information from the future within the bar. The M15 candle was still forming, but the test was using values that only exist after it closed. Live, the EA only sees what's actually available at that moment, so the results didn't match.
The fix was to read the M15 values from the last closed bar, not the current one. That means the filter reacts one bar later, but it's what actually happens in real time. After that change, the backtest improvement mostly disappeared, which told me it wasn't real.
Whenever a result looks too good after a small change, I go looking for a mistake like this before I celebrate. Using only closed bar data for anything that comes from another timeframe is a rule I follow now.