This strategy mainly uses the ADX indicator to judge the trend and combines the MA and EMA moving averages with different parameter settings to build a long-only trend tracking strategy. When ADX rises, it indicates a long direction. When the price breaks through the upward MA and EMA, open long positions. When ADX falls or the price falls below MA or EMA, close positions.
The strategy mainly uses ADX to judge market trend and strength. ADX calculates the degree and direction of price changes to determine the existence and strength of the trend. When ADX rises, it means that it is currently in an upward trend. When ADX falls, it means the trend is weakening.
The strategy also uses two moving averages, MA and EMA, with different parameter settings as auxiliary judgment. They can effectively filter the randomness of prices and show the main trend direction of prices. When prices rise and break through MA and EMA, it is a long signal. When prices fall and break through, it is a closing signal.
Combining the characteristics of ADX and moving averages, the strategy builds trading signals to judge the trend direction: go long when ADX rises and prices break through the upward MA and EMA, and close positions when ADX falls or prices break through MA/EMA. It implements a long-only trend tracking strategy.
The main advantages of this strategy are:
There are also some risks:
Solutions:
The strategy can be optimized from the following aspects:
In general, this is a long-only trend tracking strategy that uses ADX to judge the trend strength and two moving averages as auxiliary filters. It effectively controls the occurrence of invalid trades and achieves the effect of tracking trends. It is a relatively stable long-only strategy. With some optimizations, the strategy’s stability and yield can be further enhanced.
/*backtest start: 2023-01-22 00:00:00 end: 2024-01-28 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("ADX, MA, and EMA Long Strategy - ADX Trending Up", shorttitle="ADX_MA_EMA_Long_UpTrend", overlay=true) adxlen = input(14, title="ADX Smoothing") dilen = input(14, title="DI Length") maPeriod = input(50, title="MA Period") emaPeriod = input(50, title="EMA Period") dirmov(len) => up = change(high) down = -change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) truerange = rma(tr, len) plus = fixnan(100 * rma(plusDM, len) / truerange) minus = fixnan(100 * rma(minusDM, len) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) sig = adx(dilen, adxlen) maValue = sma(close, maPeriod) emaValue = ema(close, emaPeriod) longCondition = sig > sig[1] and close > maValue and close > emaValue if (longCondition) strategy.entry("Long", strategy.long) exitCondition = sig < sig[1] or close < maValue or close < emaValue if (exitCondition) strategy.close("Long") plot(maValue, color=color.blue, title="MA") plot(emaValue, color=color.orange, title="EMA") plot(sig, color=color.red, title="ADX")