
이 전략은 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)