Optimal Weighted Moving Average
May 14, 2020

The Optimal Weighted Moving Average indicator provides a dynamic trend-following tool that adjusts its weighting mechanism based on the correlation between price and the average itself to provide enhanced signal clarity.
Usage
The Usage section describes how the script can be used to identify market trends and potential entry or exit points.
- Trend Identification: Traders can use the color-coded output to determine market direction. A green line indicates a bullish trend where the price is trading above the average, while a red line indicates a bearish trend where the price is trading below the average.
- Crossovers: Buy signals occur when the price crosses above the OWMA (turning it green), and sell signals occur when the price crosses below the OWMA (turning it red).
- Multi-Timeframe Analysis: By using the Resolution setting, traders can overlay a higher-timeframe OWMA on a lower-timeframe chart to filter out market noise and trade in the direction of the primary trend.
- Sensitivity Adjustments: The Length input directly impacts the indicator's responsiveness. A shorter length is suitable for scalp trading and quick reactions, whereas a longer length helps in identifying long-term structural shifts in the market.
Details
The Optimal Weighted Moving Average was originally introduced by Thomas Hutchinson and Peter G. Zhang, Ph.D. Unlike a standard Weighted Moving Average (WMA) that uses linear weighting, the OWMA utilizes the correlation between the input source and the previous value of the indicator to determine the weights for each data point in the lookback period.
Specifically, the script calculates weights using the formula weight = (length - i) ^ correlation. This adaptive approach allows the moving average to shift its sensitivity based on how well the price is currently correlating with its own average. The script also includes a security function to handle multi-timeframe data and features built-in alert conditions for bullish and bearish changes.
Settings
- Source: Determines the price data used for the indicator calculation (e.g., Close, Open, High, Low).
- Resolution: Allows the indicator to be calculated based on a specific timeframe regardless of the current chart timeframe.
- Allow Repainting?: A toggle to enable or disable repainting behavior for higher timeframe data.
- Allow Bar Color Change?: When enabled, the price bars on the chart will change color to match the current trend signal.
- Length: Sets the lookback period used for both the moving average calculation and the correlation coefficient.
FAQ
How does the OWMA differ from a standard Moving Average? The OWMA is adaptive; it uses the correlation between price and the average as an exponent for its weights, making it more responsive to price action compared to a static simple or exponential moving average.
Can this indicator be used on any asset? Yes, the Optimal Weighted Moving Average is a versatile technical analysis tool that can be applied to equities, forex, crypto, and commodities on any timeframe.
How do I get access to the Optimal Weighted Moving Average? 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.