# L1Trend # Examples from the article [Applying L1 Trend Filtering in MetaTrader 5](https://www.mql5.com/en/articles/21142) ![Demo](L1Trend_Demo_Animation.gif) # File Structure ## Scripts - `MQL5\Scripts\TestL1Trend.mq5` Test script for calculating the L1 trend on model data (random walk). - `MQL5\Scripts\TestL1TrendFloatDouble.mq5` Test script for calculating the L1 trend on model data (random walk) for **double** and **float** vectors. - `MQL5\Scripts\TestL1TrendFilterSP500.mq5` Test script for calculating the L1 trend on S&P 500 index price data. - `MQL5\Scripts\TestScalingBrownianMotion.mq5` Script for calculating the power-law dependence of λmax for Brownian motion. - `MQL5\Scripts\TestScalingSymbol.mq5` Script for calculating the power-law dependence of λmax for the price series of a selected symbol. - `MQL5\Scripts\PlotData.py` Python script for analyzing the effectiveness of applying the L1 filter to trading signals. --- ## Data Files - `MQL5\Files\snp500.txt` Data file used by test scripts (log of the S&P 500 index price series). --- ## Indicators - `MQL5\Indicators\L1TrendFilter.mq5` Indicator for calculating the L1 trend. - `MQL5\Indicators\L1TrendFilter_Slope.mq5` Indicator for calculating the rate of change (slope) of the L1 trend. - `MQL5\Indicators\L1TrendFilter_SlopeSign.mq5` Indicator for calculating the sign of L1 trend changes. - `MQL5\Indicators\L1Volatility.mq5` Indicator for calculating residual volatility (difference between closing prices and the L1 trend). - `MQL5\Indicators\L1VolatilitySmoothed.mq5` Indicator for calculating smoothed residual volatility. - `MQL5\Indicators\L1VolatilityAbsolute.mq5` Indicator for calculating absolute volatility. - `MQL5\Indicators\L1VolatilityNormalized.mq5` Indicator for calculating normalized volatility using ATR (Average True Range) and the L1 trend. - `MQL5\Indicators\L1VolatilityNormalizedSmoothed.mq5` Indicator for calculating smoothed normalized volatility. - `MQL5\Indicators\L1VolatilityRegime.mq5` Market regime detection indicator. - `MQL5\Indicators\L1VolatilityRegimeColor.mq5` Color version of the market regime detection indicator. --- ## Expert Advisors - `MQL5\Experts\MovingAverageFilteredL1.mq5` Expert Advisor based on a Moving Average strategy with L1 filtering. - `MQL5\Experts\MACDFilteredL1.mq5` Expert Advisor based on a MACD strategy with L1 filtering. - `MQL5\Experts\ADXFilteredL1.mq5` Expert Advisor based on an ADX strategy with L1 filtering. - `MQL5\Experts\EMAFilteredL1.mq5` Expert Advisor based on crossover of two EMAs with L1 filtering.