Loading…

Loess Local Regression Line

A simple moving average weights every bar in its window equally, which is exactly why it lags: an old bar from the far edge of the window pulls just as hard as the newest one. LOESS instead fits a weighted linear regression across the window, using a tricube weight that rises smoothly toward the point being estimated, so nearby data dominates the fit while older data still contributes a softening influence rather than being dropped abruptly like a shorter moving average would. Textbook LOESS centres its window on the point being estimated, which means the fit near the right edge of a chart would need bars that have not printed yet - the classic setup for a smoother that quietly repaints as new bars arrive. This implementation uses a strictly trailing window instead: the fit at any bar only ever uses that bar and older ones, evaluated at the window's own newest edge. The result is a line that follows curvature better than a moving average while staying exactly where it was plotted once a bar closes - the "stable on already closed bars" behaviour that makes it usable for actual chart reading rather than only retrospective analysis. Notes and limitations - The trailing-window design trades some smoothness for the guarantee of no repainting - a centred LOESS would look marginally smoother near the current bar but would revise its recent values as new bars arrive, which this deliberately avoids. - A near-constant price window (zero variance in bar position weights) falls back to a plain weighted average rather than dividing by a near-zero denominator. - This is a smoother, not a signal - it plots no arrows and does not predict the next bar's direction.

Indicator · MT5 · v1.0 · Free

About Loess Local Regression Line

Loess Local Regression Line is an indicator for MetaTrader 5. It has 1 setting, such as Bandwidth. MQL source code included.

Files in the download: LoessLocalRegressionLine.ex5, LoessLocalRegressionLine.mq5, LoessLocalRegressionLine.txt.

Settings

SettingDefaultWhat it does
Bandwidth25Trailing window size the local regression is fitted over

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Moving Average · Trailing Stop & Break-even · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria