Advertisement IC Markets

R-squared as a trend filter: how well a straight line fits, and why random prices often fit surprisingly well

Discuss 1-minute to 15-minute price action setups, fading intraday momentum, key support/resistance zones, and proven short-term trading methodologies.
Post Reply
Shadow Trader
Posts: 6144
Joined: Wed Sep 09, 2026 5:19 pm

R-squared as a trend filter: how well a straight line fits, and why random prices often fit surprisingly well

Post by Shadow Trader »

The R-squared indicator takes the last n closes, fits a straight line through them with linear regression, and reports how much of the variation the line explains. A value near 1 means the closes lie close to a straight line. A value near 0 means a straight line explains almost nothing. It doesn't say which way the line slopes, so it's usually paired with the regression slope.

As a filter the idea is simple: trade trend setups when R-squared is high and the slope agrees, avoid them when R-squared is low.

The catch is statistical. Prices that follow a random walk often produce high R-squared values over short windows, because a random walk wanders and a wandering path can look like a line over 20 or 30 bars. This is the 'spurious regression' problem: trending-looking fits appear even when there's no real trend. So a high R-squared on its own doesn't show that a trend exists in any meaningful sense, only that the recent path happened to be fairly straight.

That doesn't make it useless. A straight recent path does tell you something about how orderly the move has been, which matters for pullback entries and stop placement. It just shouldn't be read as a probability that the move continues.

One check is to compute R-squared on simulated random-walk prices with the same volatility as your pair and see how often it goes above your chosen threshold, say 0.7. If random data crosses it a third of the time, your filter is mostly sorting random paths, and its value will have to be shown in an actual test rather than assumed. Has anyone done that comparison for M5 forex?
Recommended broker for automated trading & scalping IC Markets
Post Reply