Discussing the article: "Applying L1 Trend Filtering in MetaTrader 5"

 

Check out the new article: Applying L1 Trend Filtering in MetaTrader 5.

This article explores the practical application of L1 trend filtering in MetaTrader 5, covering both its mathematical foundations and usage in MQL5 programs. The L1 filter enables extraction of piecewise-linear trends that preserve essential market structure while reducing price noise. The study analyzes parameter scaling, trend estimation behavior, and integration of the method into algorithmic trading strategies. Experimental results demonstrate how L1 trend filtering can enhance signal stability, trade timing, and overall robustness of trading systems.

Financial time series are characterized by high noise levels, frequent outliers, and changing market regimes. In practical trading systems, this manifests in a simple and measurable way: classical “smooth” filters (moving averages, HP) lag behind, blur the moments of slope changes, and often interpret local corrections as reversals — as a result, the number of false entries/exits increases, the Profit Factor decreases, and drawdown grows. In addition, the selection of the regularization parameter λ is usually reduced to manual tuning and does not transfer well across instruments, timeframes, and history lengths.

This paper proposes a practical solution to these problems based on L1 trend filtering: optimization with L1 regularization of second differences automatically produces a piecewise-linear approximation with explicit breakpoints. The key advantages are a clear interpretation of breakpoints as regime changes, the ability to set the scale of regularization via computing λmax and moving to a relative parameter λ = coef · λmax, as well as linear computational complexity suitable for implementation in MQL5.

We present not only the theory, but also a complete practical roadmap: methods for computing λmax and the L1 trend, three indicators (trend, slope, slope sign), seven L1-trend volatility indicators, integration into Expert Advisors, and a reproducible testing protocol (four filtering modes, balance/equity export, and visualization).

Author: MetaQuotes

 
MetaQuotes :

The article " Using L1 Trend Filtering in MetaTrader 5" has been published:

Author: MetaQuotes

This is excellent, well done MetaQuotes.Prof. Stephen Boyd from Stanford University and his legendary time series findings in mql5.

 
cemal #:
This is excellent, well done MetaQuotes.Prof. Stephen Boyd from Stanford University and his legendary time series findings in mql5.

Thank you. The method has no boundary problems, so that's why its applications may be useful in trading.

After the article was ready, it has been found that the best way is add volume on trend corrections, (this moment is not considered in the article), see the Expert Advisors here: MA, MACD, ADX, EMA.

The Expert Advisors with adding on trend corrections:

MovingAverageFilteredL1-Add.mq5

MACDFilteredL1-Add.mq5

Пример применения L1-фильтра для удаления шума в изображениях
Пример применения L1-фильтра для удаления шума в изображениях
  • 2026.04.10
  • www.mql5.com
Настройки тестирования Параметры тестирования без фильтров Параметры тестирования с фильтром закрытия сделок L1 Close Filter Стратегия с фильтром закрытия L1 Close Filter Индикаторы тренда на базе L1 Trend Filter
 

The script shows L1 trend filtering for the different lambda (defined in λmax units as lambda_factors = {1.0,0.8,0.5,0.2,0.1,0.01,0.001});

See other examples in https://forge.mql5.io/quantum/L1Trend

L1Trend
L1Trend
  • quantum
  • forge.mql5.io
Examples from the article "Applying L1 Trend Filtering in MetaTrader 5"
Files: