RSI 인디케이터에 기반한 니프티 거래 전략

저자:차오장
태그:

img

전반적인 설명

전략 원칙

논리는 다음과 같습니다: RSI가 20보다 낮을 때, 그것은 과판 상태를 나타냅니다. 자산이 과대평가되고 리바운드가 앞두고 있음을 암시합니다. RSI가 20을 넘을 때, 길게 이동하십시오. RSI가 70보다 높을 때, 그것은 과반 구매 상태를 나타냅니다. 자산이 과대평가되고 콜백이 앞두고 있음을 암시합니다. RSI가 70을 넘을 때, 포지션을 닫습니다.

이점 분석

  1. 이 원칙은 간단하고 명확하고 이해하기 쉽고 유효합니다.
  2. 몇 가지 지표 매개 변수, 최적화 및 조정하기 쉽습니다.
  3. 단기 초과 수익을 추구하는 것은 스칼핑 거래 철학과 일치합니다.
  4. 사용자 정의 가능한 거래 기간, 다른 기대에 적응

위험 분석

이 전략의 주요 위험은 다음과 같습니다.

  1. 장기적인 추세를 파악할 수 없고, 큰 움직임을 놓칠 가능성이 높습니다.
  2. 손실을 효과적으로 통제할 수 있는 스톱 로스 메커니즘이 없습니다.

앞서 언급한 위험을 통제하기 위해 다음과 같은 측면에서 최적화를 할 수 있습니다.

  1. 과도한 적합성을 방지하기 위해 앞으로 이동 분석을 채택하십시오.
  2. 시간적 스톱 로스를 위한 스톱 로스 포인트를 설정
  3. 거래 빈도를 조절하기 위해 거래 매개 변수를 적절히 조정합니다.

최적화 방향

전략 최적화의 주요 측면:

  1. 최적의 매개 변수 조합을 찾기 위해 RSI 매개 변수를 최적화
  2. 최대 유출을 제한하기 위해 스톱 로스 메커니즘을 추가합니다.
  3. 장기적 경향을 판단하기 위해 이동 평균 등을 포함합니다.
  4. 위치 할당을 최적화하기 위해 위치 사이즈 모듈을 추가

결론


/*backtest
start: 2023-01-18 00:00:00
end: 2024-01-24 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("RSI Strategy", overlay=true,pyramiding = 1000)
rsi_period = 2
rsi_lower = 20
rsi_upper = 70

rsi_value = rsi(close, rsi_period)
buy_signal = crossover(rsi_value, rsi_lower)
sell_signal = crossunder(rsi_value, rsi_upper)
current_date1 =  input(defval=timestamp("01 Nov 2009 00:00 +0000"), title="stary Time", group="Time Settings")

current_date =  input(defval=timestamp("01 Nov 2023 00:00 +0000"), title="End Time", group="Time Settings")
investment_amount = 100000.0
start_time = input(defval=timestamp("01 Dec 2018 00:00 +0000"), title="Start Time", group="Time Settings") 
end_time = input(defval=timestamp("30 Nov 2023 00:00 +0000"), title="End Time", group="Time Settings")

in_time = time >= start_time and time <= end_time
// Variable to track accumulation.
var accumulation = 0.0
out_time = time >= end_time 

if (buy_signal )
    strategy.entry("long",strategy.long,qty= 1) 
    accumulation += 1
if (out_time)
    strategy.close(id="long")

plotshape(series=buy_signal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup)
plotshape(series=sell_signal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown)

plot(rsi_value, title="RSI", color=color.blue)
hline(rsi_lower, title="Lower Level", color=color.red)



plot(strategy.opentrades, style=plot.style_columns, 
     color=#2300a1, title="Profit first entry")
plot(strategy.openprofit, style=plot.style_line, 
     color=#147a00, title="Profit first entry")
// plot(strategy.position_avg_price, style=plot.style_columns, 
//      color=#ca0303, title="Profit first entry")
// log.info(strategy.position_size * strategy.position_avg_price)


더 많은