
この戦略は,複数の技術指標に基づくトレンド追跡取引システムであり,移動平均 (EMA),移動平均の散乱 (MACD) および相対的に強い指標 (RSI) の3つのクラシック技術指標を組み合わせて,市場の傾向の変化と動力を捉えることで取引を行う.この戦略は,高速EMA9周期 (EMA9周期) と遅いEMA21周期 (EMA21周期),MACD12,26,9周期) とRSI14などのパラメータ設定を採用し,指標が交差点と値を破るときに取引信号を発する.
戦略の核心的な論理は,複数の技術指標の協調的な確認によって市場のトレンドの転換点を認識することです.具体的には,以下の3つの側面の信号確認が含まれています:
この戦略は,複数の技術指標のクロス検証によって市場トレンドの変化を捉え,信頼性と適応性が優れている.しかし,実際の適用では,信号遅延や過剰取引などの問題には注意が必要であり,適応パラメータ,ストップダストメカニズム,市場環境認識などの導入により,戦略の安定性と収益性を高めるために最適化することが推奨されている.使用過程で,十分な歴史的データ復元とパラメータの最適化が行われ,実際の取引効果に応じて継続的に調整および改善することが推奨されている.
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-17 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA + MACD + RSI Strategy with Long and Short", overlay=true)
// Input parameters for MACD, EMA, and RSI
fast_ema_length = input.int(9, title="Fast EMA Length", minval=1)
slow_ema_length = input.int(21, title="Slow EMA Length", minval=1)
macd_short_length = input.int(12, title="MACD Short Length", minval=1)
macd_long_length = input.int(26, title="MACD Long Length", minval=1)
macd_signal_length = input.int(9, title="MACD Signal Length", minval=1)
rsi_length = input.int(14, title="RSI Length", minval=1)
rsi_oversold_level = input.int(30, title="RSI Oversold Level", minval=1)
rsi_overbought_level = input.int(70, title="RSI Overbought Level", minval=1)
// Calculate the MACD line and Signal line
[macdLine, signalLine, _] = ta.macd(close, macd_short_length, macd_long_length, macd_signal_length)
// Calculate the EMAs
fast_ema = ta.ema(close, fast_ema_length)
slow_ema = ta.ema(close, slow_ema_length)
// Calculate the RSI
rsi = ta.rsi(close, rsi_length)
// Conditions for long entry (bullish)
macd_bullish_crossover = ta.crossover(macdLine, signalLine) // MACD line crosses above Signal line
ema_bullish_crossover = ta.crossover(fast_ema, slow_ema) // Fast EMA crosses above Slow EMA
rsi_above_30 = rsi > rsi_oversold_level // RSI above 30 (not oversold)
long_condition = macd_bullish_crossover and ema_bullish_crossover and rsi_above_30
// Conditions for short entry (bearish)
macd_bearish_crossover = ta.crossunder(macdLine, signalLine) // MACD line crosses below Signal line
ema_bearish_crossover = ta.crossunder(fast_ema, slow_ema) // Fast EMA crosses below Slow EMA
rsi_below_70 = rsi < rsi_overbought_level // RSI below 70 (not overbought)
short_condition = macd_bearish_crossover and ema_bearish_crossover and rsi_below_70
// Execute long trade
if (long_condition)
strategy.entry("Long", strategy.long)
// Execute short trade
if (short_condition)
strategy.entry("Short", strategy.short)
// Plot the EMAs and MACD for visualization
plot(fast_ema, color=color.green, linewidth=2, title="Fast EMA")
plot(slow_ema, color=color.red, linewidth=2, title="Slow EMA")
plot(macdLine, color=color.blue, linewidth=2, title="MACD Line")
plot(signalLine, color=color.red, linewidth=2, title="Signal Line")
hline(30, "RSI 30", color=color.green)
hline(70, "RSI 70", color=color.red)
plot(rsi, color=color.purple, linewidth=2, title="RSI")