Discussing the article: "Real-Time Polynomial Regression: A Causal Savitzky-Golay Implementation for MQL5"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Real-Time Polynomial Regression: A Causal Savitzky-Golay Implementation for MQL5.
Every trader who has used a moving average has run into the same problem: by the time it confirms a trend has reversed, a meaningful part of the move is already over. This is not a flaw in any specific moving average — it is a direct consequence of how averaging works. A moving average blends recent and older prices together, and when the market reverses, those older prices keep pulling the average in the wrong direction for several bars afterward. This delay between what price is doing and what the average reports is what traders call lag.
This article introduces a different approach: the Savitzky-Golay filter. Instead of averaging raw prices, it fits a low-degree polynomial curve to a window of recent prices, and uses that curve to estimate the current smoothed value. A polynomial fit can represent curvature — the early signs of a turn — in a way a flat average cannot.
The filter itself is not new. It was published in 1964 by Abraham Savitzky and Marcel Golay, and has long been standard in analytical chemistry and spectroscopy for smoothing noisy instrument readings. It has seen very little use in trading, for a specific technical reason: the textbook version is non-causal — it uses data from both before and after the point being smoothed. In a lab, where the full dataset already exists, that is fine. In live trading, it is disqualifying, since tomorrow's closing price is not available today.
This article works through a causal adaptation: a version that only ever uses the current
bar and bars before it, making it usable in real time exactly like a moving average is. We derive the math and implement it in MQL5 as an indicator and an Expert Advisor. We also address a trade-off: faster reaction to trend changes increases sensitivity to a single noise bar. We measured this directly, and show the specific safeguard the accompanying Expert Advisor uses to manage it.
In practice, adapting the Savitzky-Golay filter for live trading comes with three specific challenges:
Author: Syed Jawad Hussain Naqvi