The Holy Grail strategy is a quantitative trading strategy that combines a dual moving average system with the ADX indicator. It aims to identify the direction and strength of the trend and trade at trend reversals.
The strategy uses both the 20-day exponential moving average (EMA) and the ADX indicator to identify entry opportunities. Specifically, it will issue trading signals in the following two cases:
When the ADX value is below 30 (indicating a weaker trend), and the price breaks through the 20-day EMA from below, go long;
When the ADX value is above 30 (indicating a stronger trend), and the price breaks through the 20-day EMA from above, go short.
It can be seen that this strategy relies on the ADX to judge the strength and direction of the trend, and then combines the support and resistance of the moving average to look for reversal opportunities. It integrates the concepts of trend following and mean reversion.
The biggest advantage of the Holy Grail strategy is that it takes into account both the direction and strength of the trend, which can effectively avoid false breakouts and reduce the probability of stop loss. Specifically, this strategy has the following advantages:
The Holy Grail strategy also has some risks, mainly in the following areas:
To reduce the above risks, parameters can be adjusted to achieve the best effect. Stop loss can also be set to control single losses. In addition, it is also necessary to test strategies on different varieties and cycles.
There are still many optimization directions for the Holy Grail strategy:
Adjusting parameters or adding new indicators may increase the profitability or win rate of the strategy. But any optimization requires sufficient backtesting to ensure its robustness.
In summary, the Holy Grail strategy combines the advantages of double moving averages and the ADX indicator, and uses clear trading rules to capture trend reversals. It has the potential to perform well. However, traders still need to optimize parameter combinations and stop loss rules to adapt to different market environments. Moreover, no matter how improved, it is impossible to completely avoid stop loss, which is a dilemma faced by every trading strategy.
/*backtest start: 2022-11-24 00:00:00 end: 2023-11-30 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 strategy("LAT Holy Grail v3", overlay=true) /////////////TEST TIME //////////////////////// testStartYear = input(2018, "Backtest Start Year") testStartMonth = input(4, "Backtest Start Month") testStartDay = input(15, "Backtest Start Day") testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0) testStopYear = input(2018, "Backtest Stop Year") testStopMonth = input(5, "Backtest Stop Month") testStopDay = input(30, "Backtest Stop Day") testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0) // A switch to control background coloring of the test period testPeriodBackground = input(title="Color Background?", type=bool, defval=true) testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na bgcolor(testPeriodBackgroundColor, transp=97) testPeriod() => time >= testPeriodStart and time <= testPeriodStop ? true : false ////////////////////////////////////////////////////////////////////// myema= ema(close, 20) plot(myema, color=green, title="eMA", linewidth=3) //longCondition = (crossover(close, myema)) //and adx3 < target //if (longCondition) //strategy.entry("My Long Entry Id", strategy.long) //shortCondition = (crossunder(close, myema)) //and adx3 > target //if (shortCondition) //strategy.entry("My Short Entry Id", strategy.short) ////////////////////////////////////////////////////////// /////////////////////////////////////// DMI /////////////////////////////////////////////// len3 = input(14, minval=1, title="DI Length") ///////////////////// lensig3 = input(14, title="ADX Smoothing", minval=1, maxval=50) //////////////////// up3 = change(high) /////////////////// down3 = -change(low) ////////////////// plusDM3 = na(up3) ? na : (up3 > down3 and up3 > 0 ? up3 : 0) ///////////////// minusDM3 = na(down3) ? na : (down3 > up3 and down3 > 0 ? down3 : 0) //////////////// trur3 = rma(tr, len3) /////////////// plus3 = fixnan(100 * rma(plusDM3, len3) / trur3) ////////////// minus3 = fixnan(100 * rma(minusDM3, len3) / trur3) ///////////// sum3 = plus3 + minus3 //////////// adx3 = 100 * rma(abs(plus3 - minus3) / (sum3 == 0 ? 1 : sum3), lensig3) /////////// //plot(plus3, color=green, style=circles, linewidth=2, title="+DI") ////////// //plot(minus3, color=red, style=circles, linewidth=2, title="-DI") ///////// plot(adx3, color=aqua, style=line, linewidth=3, title="ADX") //////// target = input(30, title=" ADX Target Line") /////// plot(target, color=yellow, title="ADX Target Line") ////// ///////////////////////////////////////////////////////////////////////////////////////////////// plot(hl2) /////////////////////////////////////////////// eMA SIGNAL LINE /////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////// HOLY GRAIL STRATEGY /////////////////////////////////////////////////////////////////// if (adx3 <= target) and crossover(close, myema) strategy.entry("HolyGrail", strategy.long, comment="Long") if (adx3 >= target) and crossunder(close, myema) strategy.entry("HolyGrail", strategy.short, comment="Short")