This strategy is a trend-following system based on multiple moving averages, combining trend strength confirmation and volatility capture mechanisms. It utilizes a triple moving average system of 5, 25, and 75 periods as its core, filters strong trends through the ADX indicator, and integrates a rapid volatility monitoring system for timely profit-taking. This multi-layered trading mechanism effectively identifies market trends and executes trades at appropriate times.
The strategy operates on three core mechanisms:
Specific trading rules:
Introduce Adaptive Parameters:
Enhanced Trend Confirmation:
Optimize Profit/Loss Taking:
Market Environment Classification:
The strategy builds a complete trading system through multiple moving averages, trend strength confirmation, and volatility monitoring dimensions. Its core advantages lie in its multi-level confirmation mechanism and flexible risk control system. Through the provided optimization suggestions, the strategy can further enhance its adaptability and stability. In practical application, traders are advised to optimize parameters according to specific market characteristics and combine with reasonable money management strategies.
/*backtest start: 2024-10-01 00:00:00 end: 2024-10-31 23:59:59 period: 2h basePeriod: 2h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("5SMA-25SMA Crossover Strategy with ADX Filter and Sudden Move Profit Taking", overlay=true) // パラメータの設定 sma5 = ta.sma(close, 5) sma25 = ta.sma(close, 25) sma75 = ta.sma(close, 75) // ADXの計算 length = 14 tr = ta.tr(true) plus_dm = ta.rma(math.max(ta.change(high), 0), length) minus_dm = ta.rma(math.max(-ta.change(low), 0), length) tr_sum = ta.rma(tr, length) plus_di = 100 * plus_dm / tr_sum minus_di = 100 * minus_dm / tr_sum dx = 100 * math.abs(plus_di - minus_di) / (plus_di + minus_di) adx = ta.rma(dx, length) // ロングとショートのエントリー条件 longCondition = ta.crossover(sma5, sma25) and close > sma75 and adx > 20 shortCondition = ta.crossunder(sma5, sma25) and close < sma75 and adx > 20 // 急激な変動を検知する条件(ここでは、前のローソク足に比べて0.6%以上の値動きがあった場合) suddenMove = math.abs(ta.change(close)) > close[1] * 0.006 // ポジション管理 if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.entry("Short", strategy.short) // 急激な変動があった場合、ポジションを利益確定(クローズ)する if (strategy.position_size > 0 and suddenMove) strategy.close("Long") if (strategy.position_size < 0 and suddenMove) strategy.close("Short") // エグジット条件 if (strategy.position_size > 0 and shortCondition) strategy.close("Long") if (strategy.position_size < 0 and longCondition) strategy.close("Short") // SMAとADXのプロット plot(sma5, color=color.blue, title="5SMA") plot(sma25, color=color.red, title="25SMA") plot(sma75, color=color.green, title="75SMA") plot(adx, color=color.orange, title="ADX") hline(20, "ADX Threshold", color=color.gray, linestyle=hline.style_dotted)