
この戦略は,RSI指標を用いてトレンド判断し,MACD指標と併せて市場に出るトレンド追跡型の多頭戦略である.この戦略は,トレンドフィルターとしてのEMA均等線と,リスク管理のための緊急停止メカニズムを組み合わせている.
この戦略は,主にRSI指標がトレンドの方向を判断することに依存している.RSI指標に設定されたRSI長線 ((デフォルト21) を穿戴すると,市場がのトレンドに逆転する可能性があると考える.この時点で,MACDがすでに下降傾向にある場合,現在逆転点にあることを判断することは,良い時間である.
さらに,この戦略は,EMA平均線 (デフォルトの200サイクル) をトレンドフィルターとして導入している. 価格がEMA平均線より高い場合にのみ追加を検討する. これは,不明なトレンドまたは下降トレンドの偽反転を効果的にフィルターすることができます.
ストップの場合は,通常のストップラインと緊急ストップラインを同時に設定する. RSIの下の通常のストップライン (<デフォルト86) を破るときは,平仓する.価格が大きく下落した場合,RSIの下の緊急ストップライン (<デフォルト73) を破るときは,最大損失を制御するために無条件平仓する.
この戦略は,一般的に,より伝統的なトレンド追跡型の多頭戦略である.RSIの反転点の識別,MACDのフィルター誤判,EMAの判断,損失制御のリスクを利用する.この戦略は,シンプルで直観的で,容易に理解され,市場状況の逆転を判断する際に一定の優位性を持っている.量化取引の入門戦略の一つとして使用することができる.しかし,この戦略は,最適化できるスペースが大きい.その後,入場信号,トレンドの判断,損失の停止機構などの複数の側面からさらに完善することができる.
/*backtest
start: 2022-12-28 00:00:00
end: 2024-01-03 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dravitch
//@version=4
strategy("RSI - BULL RUN (Improved)", overlay=true)
// Input
UseEmergency = input(true, "Use Emergency Exit?")
RSIlong = input(21, "RSI Long Cross")
RSIcloseLong = input(86, "RSI Close Long Position")
EmergencycloseLong = input(73, "RSI Emergency Close Long Position")
UseEMAFilter = input(true, "Use EMA Trend Filter")
EMAlength = input(200, "EMA Length for Trend Filter") // Utiliser 200 pour SMMA
// RSI
rsiValue = rsi(close, 14)
// MACD
[macdLine, signalLine, _] = macd(close, 12, 26, 9)
// EMA Trend Filter
emaTrend = sma(close, EMAlength) // Utiliser sma pour la SMMA (Simple Moving Average)
// Conditions pour les trades longs
trendUp = close > emaTrend
trendDown = close < emaTrend
longCondition = crossover(rsiValue, RSIlong) and trendDown or crossunder(macdLine, signalLine) and crossover(rsiValue, RSIlong)
longCloseCondition = crossunder(rsiValue, RSIcloseLong) and trendUp
emergencyLongCondition = crossunder(rsiValue, EmergencycloseLong)
// Plots
plot(rsiValue, color=color.white, linewidth=2, title="RSI")
// Strategy
if (longCondition)
strategy.entry("Long", strategy.long, alert_message='RSI Long Cross: LONG')
if (longCloseCondition)
strategy.close("Long", alert_message='RSI Close Long Position')
if (emergencyLongCondition and UseEmergency)
strategy.close("Long", alert_message='RSI Emergency Close Long')
// Plot EMA Trend Filter in a separate pane
plot(emaTrend, color=color.rgb(163, 0, 122), title="EMA Trend Filter", linewidth=2, style=plot.style_line, transp=0)
hline(0, "Zero Line", color=color.gray)