
The Adaptive Weighted Moving Average Cross Stacking Strategy (AWMA Cross Stacking Strategy) is a trend-following system based on the cross-relationships and stacking patterns of multiple-period Weighted Moving Averages (WMAs). The strategy ingeniously combines 6 short-period WMAs and 6 long-period WMAs, determining market trend direction and strength by observing their crossovers and relative positions. The core design philosophy aims to capture strong trend momentum while providing rule-based clear exit signals to reduce losses during trend reversals.
The core principle of this strategy is built on hierarchical analysis of weighted moving averages and multiple confirmation mechanisms:
Multi-period WMA Calculation:
Key Parameter Analysis:
Entry Conditions:
Exit Conditions:
Through this “extreme value crossover + average value confirmation” approach, the strategy can both timely capture trend formation and provide smooth exit signals when trends weaken, reducing the interference of false signals.
After a deep analysis of the strategy’s code implementation, we can summarize the following significant advantages:
Multiple Confirmation Mechanism: The strategy requires both crossover signals and stacking confirmation to execute trades, greatly reducing the risk of false breakouts. Particularly, the stacking condition (bullAlign/bearAlign) requires all short-period indicators to be on the same side of all long-period indicators, which is a very strong trend confirmation.
High Adaptability: By using multiple WMAs with different periods, the strategy can adapt to various market environments and price fluctuations. The short-period group captures immediate momentum, while the long-period group confirms the overall trend direction.
Clear Entry and Exit Rules: The strategy provides objective entry and exit signals based on mathematical models, reducing the emotional interference caused by subjective judgment.
Asynchronous Exit Mechanism: Entry is based on extreme value crossover and stacking, while exit is based on average value crossover. This design allows the strategy to hold positions longer during strong trends and exit promptly when trends weaken.
Comprehensive Notification System: The strategy integrates a JSON-based alert mechanism that can connect to external bot systems for automated trading and remote monitoring.
Visual Support: The strategy plots all 12 WMA indicator lines on the chart, allowing traders to visually observe market structure and potential signals.
Despite its sophisticated design, the strategy still has some potential risks and challenges:
Parameter Sensitivity: The strategy uses 12 different WMA period parameters, and the choice of these parameters can significantly impact strategy performance. Different markets or timeframes may require different parameter combinations for optimal results.
Poor Performance in Oscillating Markets: As a trend-following strategy, it may generate frequent false signals and “whipsaw effects” in sideways or highly volatile oscillating markets, leading to consecutive losses.
Lag Issues: All moving average-based systems have a certain lag. Although shorter WMAs are used to reduce this problem, the strategy may still miss optimal entry or exit points in rapidly reversing markets.
Computational Complexity: The strategy requires calculating and comparing multiple moving averages, which may cause performance issues on some trading platforms, especially in low timeframes or high-frequency trading environments.
Signal Congestion: Under certain market conditions, short-term and long-term WMAs may frequently cross, resulting in too many trading signals, increasing trading costs, and potentially leading to overtrading.
Based on the above analysis, the strategy can be optimized in the following aspects:
Dynamic Parameter Adjustment:
Market Environment Filtering:
Risk Management Enhancement:
Signal Quality Improvement:
Backtesting and Optimization Framework:
The Adaptive Weighted Moving Average Cross Stacking Strategy is a sophisticated trend-following system that identifies strong trends and provides clear trading signals through the crossover and stacking relationships of multiple WMAs. The core advantage of this strategy lies in its multiple confirmation mechanisms and asynchronous exit design, which can effectively capture sustainable trends and reduce false signal risks.
However, like any technical analysis strategy, it also faces challenges such as poor performance in oscillating markets and parameter sensitivity. The strategy performance can be further improved by introducing dynamic parameter adjustment, market environment filtering, and enhanced risk management mechanisms.
For traders, it’s crucial to understand the principles and limitations of this strategy. It’s recommended to conduct thorough backtesting and simulation trading before real-world application, and to adjust parameter settings according to specific trading instruments and market environments. Additionally, using this strategy as part of a broader trading system, combined with fundamental analysis and risk management principles, is key to achieving long-term stable trading results.
/*backtest
start: 2024-06-23 00:00:00
end: 2025-06-21 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("AWMA Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, calc_on_every_tick=true)
// Inputs
_Period1 = input.int(3, 'WMA1 Period')
_Period2 = input.int(5, 'WMA2 Period')
_Period3 = input.int(8, 'WMA3 Period')
_Period4 = input.int(10, 'WMA4 Period')
_Period5 = input.int(12, 'WMA5 Period')
_Period6 = input.int(15, 'WMA6 Period')
_Period7 = input.int(30, 'WMA7 Period')
_Period8 = input.int(35, 'WMA8 Period')
_Period9 = input.int(40, 'WMA9 Period')
_Period10 = input.int(45, 'WMA10 Period')
_Period11 = input.int(50, 'WMA11 Period')
_Period12 = input.int(60, 'WMA12 Period')
// Calculate WMA
wma1 = ta.wma(close, _Period1)
wma2 = ta.wma(close, _Period2)
wma3 = ta.wma(close, _Period3)
wma4 = ta.wma(close, _Period4)
wma5 = ta.wma(close, _Period5)
wma6 = ta.wma(close, _Period6)
wma7 = ta.wma(close, _Period7)
wma8 = ta.wma(close, _Period8)
wma9 = ta.wma(close, _Period9)
wma10 = ta.wma(close, _Period10)
wma11 = ta.wma(close, _Period11)
wma12 = ta.wma(close, _Period12)
// Max/Min/Average of short and long WMA groups
short_max = math.max(math.max(math.max(math.max(math.max(wma1, wma2), wma3), wma4), wma5), wma6)
short_min = math.min(math.min(math.min(math.min(math.min(wma1, wma2), wma3), wma4), wma5), wma6)
long_max = math.max(math.max(math.max(math.max(math.max(wma7, wma8), wma9), wma10), wma11), wma12)
long_min = math.min(math.min(math.min(math.min(math.min(wma7, wma8), wma9), wma10), wma11), wma12)
avg_short = (wma1 + wma2 + wma3 + wma4 + wma5 + wma6) / 6
avg_long = (wma7 + wma8 + wma9 + wma10 + wma11 + wma12) / 6
// Cross events and trend alignment
bullCross = ta.crossover(short_max, long_min)
bearCross = ta.crossunder(short_max, long_min)
bullAlign = short_min > long_max
bearAlign = short_max < long_min
// State flags
var bool readyLong = false
var bool readyShort = false
if bullCross
readyLong := true
if bearCross
readyShort := true
// Message variables
sym = syminfo.ticker
tf = timeframe.period
price = str.tostring(close)
// Entry and Alerts
if barstate.isconfirmed
if readyLong and bullAlign
strategy.entry("Long", strategy.long, comment="[AWMA] Long Entry")
readyLong := false
if readyShort and bearAlign
strategy.entry("Short", strategy.short, comment="[AWMA] Short Entry")
readyShort := false
// Exit conditions: Avg WMA cross
if ta.crossunder(avg_short, avg_long)
strategy.close("Long", comment="[AWMA] Close Long")
alert('{"text":"Long position closed\nTicker: ' + sym + '\nTimeframe: ' + tf + '\nAvg Short WMA: ' + str.tostring(avg_short) + '\nAvg Long WMA: ' + str.tostring(avg_long) + '\nClose: ' + price + '"}', alert.freq_once_per_bar_close)
if ta.crossover(avg_short, avg_long)
strategy.close("Short", comment="[AWMA] Close Short")
alert('{"text":"Short position closed\nTicker: ' + sym + '\nTimeframe: ' + tf + '\nAvg Short WMA: ' + str.tostring(avg_short) + '\nAvg Long WMA: ' + str.tostring(avg_long) + '\nClose: ' + price + '"}', alert.freq_once_per_bar_close)
// Plotting
plot(wma1, color=color.new(#4fc3d2, 0), title='Short WMA 1')
plot(wma2, color=color.new(#4fc3d2, 0), title='Short WMA 2')
plot(wma3, color=color.new(#4fc3d2, 0), title='Short WMA 3')
plot(wma4, color=color.new(#4fc3d2, 0), title='Short WMA 4')
plot(wma5, color=color.new(#4fc3d2, 0), title='Short WMA 5')
plot(wma6, color=color.new(#4fc3d2, 0), title='Short WMA 6')
plot(wma7, color=color.new(#fe0d5f, 0), title='Long WMA 1')
plot(wma8, color=color.new(#fe0d5f, 0), title='Long WMA 2')
plot(wma9, color=color.new(#fe0d5f, 0), title='Long WMA 3')
plot(wma10, color=color.new(#fe0d5f, 0), title='Long WMA 4')
plot(wma11, color=color.new(#fe0d5f, 0), title='Long WMA 5')
plot(wma12, color=color.new(#fe0d5f, 0), title='Long WMA 6')
// Uncomment if you want to show the averages
// plot(avg_short, color=color.new(#00FF00, 0), title='Avg Short WMA')
// plot(avg_long, color=color.new(#FF0000, 0), title='Avg Long WMA')