The Dual Moving Average ADX Timing strategy identifies trends by combining 2/20 moving averages and the ADXR indicator to generate trading signals at the beginning of trends. It first uses the 2/20 exponential moving averages to determine the price trend direction, then further confirms the trend signal in combination with the ADXR indicator, thus producing more reliable trading signals.
The core logic of the Dual Moving Average ADX Timing strategy is based on the following main components:
2/20 Exponential Moving Average (EMA)
ADXR Indicator
Trading signals
The main innovation of this strategy is using ADXR indicator to identify trends in initial stage, and combining it with traditional moving average signals to improve quality and stability.
The main advantages of the Dual Moving Average ADX Timing strategy:
There are also several main risks for this strategy:
Improper ADXR parameter setting may lead to missing trades.
More false signals may occur in special market conditions.
Fixed EMA parameters fail to adapt to market changes.
Unable to identify trading ranges, may generate excessive insignificant trades.
The strategy can be further optimized and enhanced from the following aspects:
EMA parameter optimization for automatic adaptation to market conditions.
Expand ADXR parameter range for capturing more effective trading signals.
Add extra trend judgment indicators for combinational signals to improve quality.
Add stop loss strategies and take profit standards to control per trade risks.
Optimize money management for dynamic position sizing based on account status.
The Dual Moving Average ADX Timing strategy innovatively combines traditional dual moving averages and the ADXR indicator to improve signal quality and enhance stability. It can effectively identify the initial stage of trends with decent historical performance. The strategy has ample room for optimization to make it robust and profitable across more complex markets.
/*backtest start: 2023-11-05 00:00:00 end: 2023-12-05 00:00:00 period: 2h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 04/04/2022 // This is combo strategies for get a cumulative signal. // // First strategy // This indicator plots 2/20 exponential moving average. For the Mov // Avg X 2/20 Indicator, the EMA bar will be painted when the Alert criteria is met. // // Second strategy // The Average Directional Movement Index Rating (ADXR) measures the strength // of the Average Directional Movement Index (ADX). It's calculated by taking // the average of the current ADX and the ADX from one time period before // (time periods can vary, but the most typical period used is 14 days). // Like the ADX, the ADXR ranges from values of 0 to 100 and reflects strengthening // and weakening trends. However, because it represents an average of ADX, values // don't fluctuate as dramatically and some analysts believe the indicator helps // better display trends in volatile markets. // // // WARNING: // - For purpose educate only // - This script to change bars colors. //////////////////////////////////////////////////////////// EMA20(Length) => pos = 0.0 xPrice = close xXA = ta.ema(xPrice, Length) nHH = math.max(high, high[1]) nLL = math.min(low, low[1]) nXS = nLL > xXA or nHH < xXA ? nLL : nHH iff_1 = nXS < close[1] ? 1 : nz(pos[1], 0) pos := nXS > close[1] ? -1 : iff_1 pos fADX(Len) => up = ta.change(high) down = -ta.change(low) trur = ta.rma(ta.tr, Len) plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, Len) / trur) minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, Len) / trur) sum = plus + minus 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), Len) ADXR(LengthADX,LengthADXR,Signal1,Signal2) => pos = 0.0 xADX = fADX(LengthADX) xADXR = (xADX + xADX[LengthADXR]) / 2 pos := xADXR < Signal1 ? 1 : xADXR > Signal2 ? -1 : nz(pos[1], 0) pos strategy(title='Combo 2/20 EMA & ADXR', shorttitle='Combo', overlay=true) var I1 = '●═════ 2/20 EMA ═════●' Length = input.int(14, minval=1, group=I1) var I2 = '●═════ ADXR ═════●' LengthADX = input(title="Length ADX", defval=14) LengthADXR = input(title="Length ADXR", defval=14) Signal1 = input.float(13, step=0.01) Signal2 = input.float(45, step=0.01) var misc = '●═════ MISC ═════●' reverse = input.bool(false, title='Trade reverse', group=misc) var timePeriodHeader = '●═════ Time Start ═════●' d = input.int(1, title='From Day', minval=1, maxval=31, group=timePeriodHeader) m = input.int(1, title='From Month', minval=1, maxval=12, group=timePeriodHeader) y = input.int(2005, title='From Year', minval=0, group=timePeriodHeader) StartTrade = time > timestamp(y, m, d, 00, 00) ? true : false posEMA20 = EMA20(Length) prePosADXR = ADXR(LengthADX,LengthADXR,Signal1,Signal2) iff_1 = posEMA20 == -1 and prePosADXR == -1 and StartTrade ? -1 : 0 pos = posEMA20 == 1 and prePosADXR == 1 and StartTrade ? 1 : iff_1 iff_2 = reverse and pos == -1 ? 1 : pos possig = reverse and pos == 1 ? -1 : iff_2 if possig == 1 strategy.entry('Long', strategy.long) if possig == -1 strategy.entry('Short', strategy.short) if possig == 0 strategy.close_all() barcolor(possig == -1 ? #b50404 : possig == 1 ? #079605 : #0536b3)