Moving Averages Linear Combinator
Mar 15, 2020

The Moving Averages Linear Combinator tool enables users to create custom trend-following outputs by mathematically combining two different moving average types to reduce lag or enhance price reactivity.
Usage
The Usage section describes how the script can be used to engineer specific moving average behaviors. By combining a faster "leading" moving average with a slower "lagging" moving average, users can create a composite line that filters noise while remaining more responsive to price action than standard indicators.
- Lag Reduction: To achieve a low-lag result, the leading moving average should be more reactive (shorter period or faster type) than the lagging moving average.
- Trend Analysis: The resulting combination can be used to identify trend direction or generate crossover signals with price.
- Visual Comparison: Users can toggle the visibility of the underlying leading and lagging components to better understand how the linear combination is derived relative to standard averages.
Details
The indicator is based on a linear combination formula: Coeff × LeadingMA(length1) - (Coeff - 1) × LaggingMA(length2)
In mathematics, a linear combination is an expression formed by multiplying terms by specified coefficients and adding the results. This script specifically utilizes this to create a "bandpass" effect. For example, using a coefficient of 2 with a fast SMA and a slow SMA effectively adds a momentum component to the trend line, which compensates for the inherent lag found in traditional moving averages. Many well-known indicators, such as the Hull Moving Average (HMA) and Double Exponential Moving Average (DEMA), utilize similar linear combination principles.
Settings
- Length: Sets the base period for the lagging moving average.
- Leading: Selects the calculation method for the leading moving average (SMA, EMA, WMA, HMA, VWMA, TMA, or LSMA).
- Lagging: Selects the calculation method for the lagging moving average, including an option for an external input source.
- Coefficient: Determines the weight of the linear combination. Higher values amplify the responsiveness and the "de-lagging" effect. A coefficient of 1 returns only the leading MA, while -1 returns the lagging MA.
- Leading Period Divisor: Divides the base length to determine the period of the leading MA. A higher divisor makes the leading MA more reactive.
- External Input: Allows the user to select a separate indicator or source to be used as the "Lagging" component.
- Source: Determines the price data used for calculations (e.g., Close, Open, High, Low).
- Plot Leading & Lagging MA's: A toggle to show or hide the two individual moving averages used in the combination.
FAQ
How can I reduce the lag of the combined moving average? Increase the "Coefficient" value or increase the "Leading Period Divisor." This places more mathematical weight on the faster component, making the final output follow price more closely.
What moving average types can I combine? You can mix and match between Simple (SMA), Exponential (EMA), Weighted (WMA), Hull (HMA), Volume Weighted (VWMA), Triangular (TMA), and Least Squares (LSMA) moving averages.
How do I access the Moving Averages Linear Combinator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.