New bar detection in EAs: the bug behind doubled or missing signals
Posted: Sat Oct 17, 2026 8:30 am
New bar detection in EAs: the bug behind doubled or missing signals
Most EAs that trade on bar closes need to know when a new bar has started. The common approach is storing the time of the last bar and checking on each tick whether the current bar's open time has changed. Simple, but it's a classic source of bugs.
Doubled signals happen when the stored time isn't updated correctly, or is reset when the EA restarts. The EA sees the same bar as new twice and trades twice. Restarting the platform mid-bar is a common trigger.
Missing signals happen when no tick arrives at the start of a bar for a while, especially on quiet pairs or at odd hours. The EA only finds out about the new bar when a tick comes in, which might be well into the bar. If the logic depends on acting at the bar open, it's late.
Timeframe mismatches cause their own trouble. If the EA checks for a new bar on the chart timeframe but the signal uses another timeframe, it might evaluate the signal at the wrong time.
What helps: store the last bar time as a global variable or in a file so it survives restarts. Check the bar time of the specific timeframe the signal uses. And log every time the EA detects a new bar, so you can verify it's doing what you expect.
Most EAs that trade on bar closes need to know when a new bar has started. The common approach is storing the time of the last bar and checking on each tick whether the current bar's open time has changed. Simple, but it's a classic source of bugs.
Doubled signals happen when the stored time isn't updated correctly, or is reset when the EA restarts. The EA sees the same bar as new twice and trades twice. Restarting the platform mid-bar is a common trigger.
Missing signals happen when no tick arrives at the start of a bar for a while, especially on quiet pairs or at odd hours. The EA only finds out about the new bar when a tick comes in, which might be well into the bar. If the logic depends on acting at the bar open, it's late.
Timeframe mismatches cause their own trouble. If the EA checks for a new bar on the chart timeframe but the signal uses another timeframe, it might evaluate the signal at the wrong time.
What helps: store the last bar time as a global variable or in a file so it survives restarts. Check the bar time of the specific timeframe the signal uses. And log every time the EA detects a new bar, so you can verify it's doing what you expect.