The combination strategy of dual moving average reversal and ATR trailing stop is a very practical quantitative trading strategy. The strategy first uses the death cross and golden cross formed by the dual moving averages to determine market trends and reversal points. At the same time, the strategy also combines the average true range to set trail stops to ensure profit while controlling risks.
The dual moving average reversal strategy uses the crossover of fast and slow lines to determine market trends. When the fast line crosses below the slow line from top to bottom, it forms a death cross, indicating the market trend is changing from rising to falling. When the fast line crosses above the slow line from bottom to top, it forms a golden cross, indicating the market trend is changing from falling to rising. The strategy goes short on death cross and goes long on golden cross.
Specifically, the strategy uses the 9-day STOCH fast line as the fast line and 3-day EMA as the slow line. When close is lower than previous close and fast line crosses above 50 to cross above slow line, it clears position to go short. When close is higher than previous close and fast line crosses below 50 to cross below slow line, it clears position to go long.
The ATR trailing stop strategy uses the average true range to set stop loss points. The ATR indicator can effectively reflect the short-term volatility of the market. The strategy sets trail stop based on the value of ATR to exit when price trend reverses.
Specifically, the strategy uses 5-day ATR and sets stop loss point at close minus 3.5 times ATR. When price hits the stop loss point, it closes position for stop loss.
The combination strategy of dual moving average reversal and ATR trailing stop combines the advantage of moving average strategy in determining trends and reversals and the advantage of ATR trail stop strategy in controlling risks, making it a very practical strategy.
Specifically, the strategy has the following advantages:
Use the death cross and golden cross formed by dual moving averages to determine market trend reversal points and accurately identify reversal signals.
Combine STOCH indicator to confirm reversal signals and avoid false signals.
ATR trailing stop flexibly sets stop loss points based on market volatility to maximize profit locking.
The strategy integrates multiple indicators and technical analysis methods to make the strategy more robust.
The strategy idea is clear and easy to understand, parameters are flexible for adjustment, and it is easy to operate in live trading.
Although the strategy has many advantages, there are still some risks to note:
The signals generated by dual moving averages may lag and unable to accurately buy and sell at reversal points. Periods can be moderately shortened or combined with other indicators for optimization.
ATR indicator is not sensitive to large market fluctuations and cannot update stop loss in time. Consider combining momentum indicators or volatility indicators for adjustment.
The combination of multiple parameters and conditions increases the complexity of the strategy. Improper parameters may cause overly aggressive trading and increase risks. Parameters need to be carefully evaluated and adjusted gradually.
According to the above risk analysis, the strategy can be optimized in the following aspects:
Adjust moving average period parameters to shorten periods for early capturing reversal opportunities.
Add other indicators to determine reversal signals, such as MACD, KD, etc. to form multiple confirmations.
Dynamically adjust ATR periods or introduce market volatility to update stop loss in real time.
Evaluate the differences between stock and futures markets, and adjust parameters respectively to make them more suited to both markets.
Add trading costs and slippage in backtesting to make the strategy closer to the live trading environment.
Consider adding machine learning models to dynamically optimize multiple parameters.
The combination strategy of dual moving average reversal and ATR trailing stop is an efficient and practical quantitative strategy. It combines the dual advantages of determining market reversal with moving averages and controlling risks by setting ATR trail stops. It ensures profit while reducing unnecessary losses. The strategy has flexible parameter adjustment and is easy to operate in live trading. At the same time, it can also be extended and optimized in multiple aspects to adapt to more extensive market environments. Overall, the strategy provides an excellent strategic framework for quantitative trading.
/*backtest start: 2023-12-26 00:00:00 end: 2024-01-25 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 17/05/2019 // This is combo strategies for get // a cumulative signal. Result signal will return 1 if two strategies // is long, -1 if all strategies is short and 0 if signals of strategies is not equal. // // First strategy // This System was created from the Book "How I Tripled My Money In The // Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies. // The strategy buys at market, if close price is higher than the previous close // during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. // The strategy sells at market, if close price is lower than the previous close price // during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50. // // Secon strategy // Average True Range Trailing Stops Strategy, by Sylvain Vervoort // The related article is copyrighted material from Stocks & Commodities Jun 2009 // // WARNING: // - For purpose educate only // - This script to change bars colors. //////////////////////////////////////////////////////////// Reversal123(Length, KSmoothing, DLength, Level) => vFast = sma(stoch(close, high, low, Length), KSmoothing) vSlow = sma(vFast, DLength) pos = 0.0 pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1, iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) pos ATR_TrailingStop(nATRPeriod, nATRMultip) => xATR = atr(nATRPeriod) nLoss = nATRMultip * xATR pos = 0.0 xATRTrailingStop = 0.0 xATRTrailingStop := iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss), iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss))) pos := iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1, iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) pos strategy(title="Combo Backtest 123 Reversal & Average True Range Trailing Stops", shorttitle="Combo", overlay = true) Length = input(14, minval=1) KSmoothing = input(1, minval=1) DLength = input(3, minval=1) Level = input(50, minval=1) nATRPeriod = input(5) nATRMultip = input(3.5) reverse = input(false, title="Trade reverse") posReversal123 = Reversal123(Length, KSmoothing, DLength, Level) posATR_TrailingStop = ATR_TrailingStop(nATRPeriod, nATRMultip) pos = iff(posReversal123 == 1 and posATR_TrailingStop == 1 , 1, iff(posReversal123 == -1 and posATR_TrailingStop == -1, -1, 0)) possig = iff(reverse and pos == 1, -1, iff(reverse and pos == -1, 1, pos)) 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 ? red: possig == 1 ? green : blue )