Bitlinc MARSI 거래 전략

저자:차오장, 날짜: 2024-02-29 10:54:45
태그:

img

전반적인 설명

이 전략은 연간 조정에 기반한 RSI 오스실레이션 추적 전략이다. 설정된 상위 및 하위 대역 사이의 RSI 지표의 오스실레이션 특성을 추적함으로써, RSI 지표가 상위 및 하위 대역에 닿을 때 거래 신호가 발행됩니다.

전략 원칙

  1. MA 길이, RSI, 상부/하부 밴드, 수익/손실 중지, 거래 주기의 범위에 대한 매개 변수를 설정합니다.
  2. RSI 값을 계산합니다. RSI = (평균 상승세 변화) / (평균 상승세 변화 + 평균 하락세 변화) *100
  3. 그래프 RSI 라인 및 밴드
  4. RSI가 하단역 아래로 넘어가면 긴 신호이고, 상단역 위로 넘어가면 짧은 신호입니다.
  5. OCO 명령과 함께 오픈 포지션
  6. 설정에 따라 스톱 로스를 실행하고 이윤을 취합니다.

이점 분석

  1. 연간 거래 주기를 설정하면 부적절한 외부 환경을 피할 수 있습니다.
  2. RSI는 과잉 구매/ 과잉 판매를 효율적으로 반영합니다. 합리적인 범위 오스칠레이션은 소음을 필터합니다.
  3. OCO 명령 + 스톱 로스/프로프트 설정은 효율적인 리스크 통제를 가능하게 합니다.

위험 분석

  1. RSI 임계 판단의 정확성은 보장될 수 없으며 잘못된 판단이 발생할 수 있습니다.
  2. 부적절한 연주기 설정은 더 나은 기회를 놓칠 수도 있고 부적절한 환경에 들어갈 수도 있습니다.
  3. 너무 큰 스톱 로스 설정은 큰 손실로 이어질 수 있고, 너무 작은 수익 설정은 작은 수익으로 이어질 수 있습니다.

RSI 매개 변수, 거래 사이클 범위, 스톱 로스/이익 비율을 조정하는 방법과 같은 방법을 최적화 할 수 있습니다.

최적화 방향

  1. 다양한 시장과 주기에 최적의 RSI 매개 변수를 테스트합니다.
  2. 전체 시장 사이클 패턴을 분석하고 가장 좋은 연간 거래 단계를 설정
  3. 백테스트를 통해 합리적인 스톱 로스/이익 비율을 결정
  4. 거래 상품 선택 및 위치 크기를 최적화
  5. 추가 최적화를 위해 다른 더 나은 기술과 결합

요약

이 전략은 RSI의 연주기 오스실레이션 특징에 의해 트렌드를 추적하여 거래 위험을 효과적으로 제어합니다. 매개 변수 조정 및 논리 최적화로 더 많은 성능 향상을 달성 할 수 있습니다.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy(title = "Bitlinc MARSI Study AST",shorttitle="Bitlinc MARSI Study AST",default_qty_type = strategy.percent_of_equity, default_qty_value = 100,commission_type=strategy.commission.percent,commission_value=0.1,initial_capital=1000,currency="USD",pyramiding=0, calc_on_order_fills=false)

// === General Inputs ===
lengthofma = input(62, minval=1, title="Length of MA")
len = input(31, minval=1, title="Length")
upperband = input(89, minval=1, title='Upper Band for RSI')
lowerband = input(10, minval=1, title="Lower Band for RSI")
takeprofit =input(1.25, title="Take Profit Percent")
stoploss =input(.04, title ="Stop Loss Percent")
monthfrom =input(8, title = "Month Start")
monthuntil =input(12, title = "Month End")
dayfrom=input(1, title= "Day Start")
dayuntil=input(31, title= "Day End")

// === Innput Backtest Range ===
//FromMonth = input(defval = 9, title = "From Month", minval = 1, maxval = 12)
//FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
//FromYear  = input(defval = 2018, title = "From Year", minval = 2017)
//ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
//ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
//ToYear    = input(defval = 9999, title = "To Year", minval = 2017)

// === Create RSI ===
src=sma(close,lengthofma)
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi,linewidth = 2, color=purple)

// === Plot Bands ===
band1 = hline(upperband)
band0 = hline(lowerband)
fill(band1, band0, color=blue, transp=95)

// === Entry and Exit Methods ===
longCond =  crossover(rsi,lowerband)
shortCond =  crossunder(rsi,upperband)

// === Long Entry Logic ===
if (  longCond ) 
    strategy.entry("LONG", strategy.long, stop=close, oca_name="TREND", comment="LONG")
else
    strategy.cancel(id="LONG")

// === Short Entry Logic ===    
if ( shortCond   ) 
    strategy.entry("SHORT", strategy.short,stop=close, oca_name="TREND",  comment="SHORT")
else
    strategy.cancel(id="SHORT")

// === Take Profit and Stop Loss Logic ===
//strategy.exit("Take Profit LONG", "LONG", profit = close * takeprofit / syminfo.mintick, loss = close * stoploss / syminfo.mintick)
//strategy.exit("Take Profit SHORT", "SHORT", profit = close * takeprofit / syminfo.mintick, loss = close * stoploss / syminfo.mintick)
strategy.exit("LONG TAKE PROFIT", "LONG", profit = close * takeprofit / syminfo.mintick)
strategy.exit("SHORT STOP LOSS", "SHORT", profit = close * takeprofit / syminfo.mintick)
strategy.exit("LONG STOP LOSS", "LONG", loss = close * stoploss / syminfo.mintick)
strategy.exit("SHORT STOP LOSS", "SHORT", loss = close * stoploss / syminfo.mintick)



더 많은