The CUSUM filter: sampling the market when something has actually moved, instead of every bar
Posted: Tue Nov 24, 2026 4:16 pm
Most backtests evaluate a rule on every bar: check conditions at the close of each M1 or M5 candle. But a lot of those bars are nothing, price drifting inside a tight range. The CUSUM filter is a simple way to sample only when something has happened.
The idea comes from quality control, where cumulative sums were used to detect when a process had drifted. Applied to prices, you keep two running sums of returns, one for upward moves and one for downward moves. Each one adds the latest return and is floored at zero, so small back-and-forth movement keeps resetting it. When either sum crosses a threshold h, you record an event at that bar and reset the sums.
The result is a list of moments where price has moved a meaningful amount in one direction since the last event, which makes a natural set of candidate entries for a model or a rule. Quiet periods produce few events, busy ones produce many, and that's roughly how a discretionary scalper's attention works too.
A few points to think about:
- The threshold should usually scale with volatility. A fixed 10 pips fires constantly in the London open and almost never late in the Asian session. Tying h to recent ATR or standard deviation keeps the event rate more even.
- It's a sampling rule, not a signal. An event says price moved; it doesn't say whether it will continue or reverse. That still needs a rule or a model on top.
- It cuts overlap between samples, which helps if you're training anything on the events.
The same idea also works as a change detector on your own results: a CUSUM of trade R-multiples against the expected average can flag when performance has drifted away from what the backtest suggested.
Has anyone used event-based sampling like this instead of fixed bars? I'd be interested to hear whether it changed the conclusions of any tests.
The idea comes from quality control, where cumulative sums were used to detect when a process had drifted. Applied to prices, you keep two running sums of returns, one for upward moves and one for downward moves. Each one adds the latest return and is floored at zero, so small back-and-forth movement keeps resetting it. When either sum crosses a threshold h, you record an event at that bar and reset the sums.
The result is a list of moments where price has moved a meaningful amount in one direction since the last event, which makes a natural set of candidate entries for a model or a rule. Quiet periods produce few events, busy ones produce many, and that's roughly how a discretionary scalper's attention works too.
A few points to think about:
- The threshold should usually scale with volatility. A fixed 10 pips fires constantly in the London open and almost never late in the Asian session. Tying h to recent ATR or standard deviation keeps the event rate more even.
- It's a sampling rule, not a signal. An event says price moved; it doesn't say whether it will continue or reverse. That still needs a rule or a model on top.
- It cuts overlap between samples, which helps if you're training anything on the events.
The same idea also works as a change detector on your own results: a CUSUM of trade R-multiples against the expected average can flag when performance has drifted away from what the backtest suggested.
Has anyone used event-based sampling like this instead of fixed bars? I'd be interested to hear whether it changed the conclusions of any tests.