Trend Indicators

WMA: Weighted Moving Average for Trend | AlfaTactix

📖 5 min read

📝 819 words

🏷️ Trend Indicators

In this page: what WMA is, how it works, when to use it, a practical example with code, and a bonus tip.

Use WMA in a real strategy—no code required

Create a free account to save your progress and build strategies with this indicator and 80+ others in minutes. Backtest, then export to MQL5.


WMA on a price chart: illustration of the indicator and how it is used in technical analysis
WMA – chart illustration

WMA (Weighted Moving Average) Indicator Explanation

The Weighted Moving Average (WMA) is a trend-following indicator that assigns greater weight to recent prices while still considering older price data. Unlike the Simple Moving Average (SMA) which treats all prices equally, WMA gives more importance to recent price action, making it more responsive to current market conditions. This weighting scheme helps traders identify trend changes earlier while maintaining some smoothing effect from historical data.

How WMA Works: WMA is calculated by multiplying each price in the period by a weight factor, with the most recent price receiving the highest weight and older prices receiving progressively lower weights. The weights are typically assigned in a linear fashion: the most recent price gets a weight equal to the period length, the second most recent gets period-1, and so on. The sum of all weighted prices is then divided by the sum of all weights. This mathematical approach ensures that recent price movements have a stronger influence on the indicator value, making WMA more sensitive to price changes than SMA while still providing trend smoothing.

When to Use WMA:

  • Trend Identification: WMA helps identify trend direction and changes more quickly than SMA, making it useful for traders who want earlier entry signals in trending markets.
  • Dynamic Support/Resistance: WMA can act as dynamic support in uptrends or resistance in downtrends, providing entry and exit levels that adapt to current market conditions.
  • Crossover Strategies: WMA crossovers with price or other moving averages generate trading signals faster than SMA-based systems, useful for short to medium-term trading strategies.

Advantages:

  • More responsive to recent price changes than SMA, providing earlier trend reversal signals and reducing lag in trend-following strategies.
  • Maintains smoothing properties while being more sensitive to current market conditions, offering a balance between responsiveness and noise reduction.
  • Works effectively across multiple timeframes and asset classes, from intraday trading to swing trading in stocks, forex, and cryptocurrencies.

Limitations:

  • WMA can generate more false signals than SMA during ranging markets due to its increased sensitivity to price fluctuations, requiring additional confirmation from other indicators.
  • The weighting scheme may not be optimal for all market conditions, as some traders prefer exponential weighting (EMA) or other smoothing methods depending on their trading style.
  • Like all moving averages, WMA is a lagging indicator and will always trail behind price action, making it less effective for predicting future price movements.

In summary, WMA is a valuable trend indicator for traders seeking a balance between responsiveness and smoothing. For comprehensive understanding, refer to technical analysis literature such as Investopedia's WMA guide, TradingView's WMA documentation, and academic research on moving average strategies published in financial journals.

Practical Example: Using the WMA Indicator in a Trading Strategy

The Weighted Moving Average (WMA) is a trend-following indicator that gives more weight to recent prices, making it more responsive to current market conditions than Simple Moving Average. In a trading strategy, the WMA indicator helps identify trend direction and generate entry signals based on price crossovers and trend confirmation.

Scenario: You're creating a trend-following strategy for Bitcoin (BTC/USDT) on a 1-hour chart. You want to buy when price crosses above WMA(20) in an uptrend and sell when price crosses below WMA(20) in a downtrend, capturing momentum while reducing false signals.

Strategy Logic:

  • Calculate the WMA(20) to identify the current trend direction.
  • Buy signal: When price crosses above WMA(20) and WMA(20) is above WMA(50), indicating bullish momentum and trend confirmation.
  • Sell signal: When price crosses below WMA(20) and WMA(20) is below WMA(50), indicating bearish momentum and trend reversal.

Backtrader Example:

import backtrader as bt

class WMATrendStrategy(bt.Strategy):
    params = dict(
        wma_fast=20,
        wma_slow=50
    )
    
    def __init__(self):
        self.wma_fast = bt.ind.WeightedMovingAverage(period=self.p.wma_fast)
        self.wma_slow = bt.ind.WeightedMovingAverage(period=self.p.wma_slow)
        
    def next(self):
        if not self.position:
            # Buy when price crosses above fast WMA and fast WMA is above slow WMA
            if (self.data.close[0] > self.wma_fast[0] and 
                self.data.close[-1] <= self.wma_fast[-1] and
                self.wma_fast[0] > self.wma_slow[0]):
                self.buy()
        else:
            # Sell when price crosses below fast WMA or fast WMA crosses below slow WMA
            if (self.data.close[0] < self.wma_fast[0] and 
                self.data.close[-1] >= self.wma_fast[-1]) or                (self.wma_fast[0] < self.wma_slow[0] and self.wma_fast[-1] >= self.wma_slow[-1]):
                self.sell()

# Usage
cerebro = bt.Cerebro()
cerebro.addstrategy(WMATrendStrategy)

Expected Outcome: By using the WMA indicator, your strategy captures trend changes earlier than SMA-based systems, helping you enter trades when momentum is building and exit before significant reversals. This approach leads to better entry timing, reduced lag in trend identification, and improved profit potential in trending markets.

💡 Bonus Tip

Consider using WMA in combination with volume indicators for confirmation. When price crosses above WMA with increasing volume, it suggests strong buying interest and higher probability of trend continuation. This technique, documented in technical analysis literature, can significantly improve the reliability of WMA-based trading strategies.

Using the WMA indicator ensures your strategy responds quickly to trend changes while maintaining trend-following discipline, improving entry and exit timing based on weighted price analysis.

Use WMA in a real strategy—no code required

Create a free account to save your progress and build strategies with this indicator and 80+ others in minutes. Backtest, then export to MQL5.

Try Strategy Builder

Use this indicator in Strategy Builder — free

Create free account