상승성 오차 단기 장기 무역 검색 전략

저자:차오장, 날짜: 2023-11-10 11:37:37
태그:

img

전반적인 설명

이 전략은 RSI 지표에서 상승하는 분산 패턴을 검색하여 비트코인이 반등할 가능성이 있는 단기적 기회를 식별하고, 따라서 긴 거래에 대한 좋은 입구 지점을 결정합니다.

전략 논리

  1. RSI 지표로 상승차이를 식별합니다

    • RSI 매개 변수를 정의합니다 (디폴트 14 기간)
    • 현재 RSI 값을 계산합니다.
    • 다음의 상승성 오차가 있는지 확인합니다.
      • RSI는 낮은 하위치를 형성
      • 가격은 동시에 낮은 하락을 형성
      • RSI는 더 높은 하위치를 형성
      • 그 다음 가격이 높은 낮은 형성
  2. RSI 값이 임계치 이하인지 확인합니다.

    • RSI 낮은 임계값을 정의합니다 (디폴트 40)
    • 만약 현재 RSI가 이 임계치 이하라면, 그것은 긴 입점 지점을 신호할 수 있습니다.
  3. 닫기 가격이 이전 오차 하위보다 낮는지 확인

    • 만약 네라면, 상승차별 구매 신호를 더 검증합니다.
  4. 스톱 로스 출구 조건을 정의합니다

    • 정지 손실 비율 (예정값 5%)
    • 이 비율에 도달하면 출구
  5. 이윤 취출 조건 정의

    • RSI 높은 임계값을 설정합니다 (예정값 75)
    • RSI가 이 임계치를 넘으면 종료

이점 분석

  1. RSI 분리를 사용하면 단기 가격 반등의 기회를 효과적으로 포착 할 수 있습니다.

  2. RSI의 낮은 임계값과 결합하면 특정 입구점을 결정하는 데 도움이 됩니다.

  3. 손해를 멈추고 이익을 취하는 설정은 위험과 보상을 관리하는 데 도움이됩니다.

  4. 이 전략은 비트코인 RSI 신호에 대한 실제 거래 경험을 많이 참조하고 비트코인 장기 스칼핑에 매우 적합합니다.

  5. 합리적인 매개 변수 설정으로 전략은 다른 시장 조건에 적응할 수 있고 실시간 거래에 적합합니다.

위험 분석

  1. RSI의 오차가 실패할 수 있고, 잘못된 식별으로 거래가 손실될 수 있습니다.

  2. 단일 지표는 잘못된 신호를 생성하는 경향이 있습니다. 다른 지표와 결합해야 합니다.

  3. 적절한 매개 변수 값을 선택해야 합니다, 잘못된 설정은 수익성에 영향을 미칩니다

  4. 긴 거래는 전체 트렌드를 고려하고 트렌드에 반대하는 거래를 피해야합니다.

  5. 거래 비용에 주의해야 합니다. 높은 주파수 거래는 이익에 영향을 미칩니다.

  6. 변화하는 시장에 따라 매개 변수를 정기적으로 테스트하고 최적화해야합니다.

최적화 방향

  1. 잘못된 신호를 줄이기 위해 필터 조건의 이동 평균과 같은 다른 지표를 추가하는 것을 고려하십시오.

  2. 최적의 조합을 찾기 위해 각 시간 프레임에 다른 기간 설정을 테스트

  3. 트렌드 전환에 대한 구매를 피하기 위해 더 긴 시간 프레임 트렌드 분석을 포함합니다.

  4. 이윤 수준이 증가함에 따라 점진적으로 스톱 손실을 올리는 동적 스톱 손실을 구현하십시오.

  5. 특정 포지션 사이징에 기초한 스톱 로스 비율 조정

  6. 자동 매개 변수 최적화를 위한 기계 학습을 도입

결론

이 전략은 RSI가 상승하는 오차를 감지하고 좋은 긴 입구 지점을 결정함으로써 비트코인의 단기 반등 기회를 식별하는 것을 목표로 한다. 이 전략은 간단하고 효과적이며, 많은 실용적인 거래 경험을 통합하여 비트코인 스칼핑 로그에 매우 적합하다. 그러나 단일 지표에 의존하는 것은 잘못된 신호를 생성하는 경향이 있으므로 다른 지표와 결합되어야 한다. 또한 매개 변수 최적화, 스톱 로스 배치, 거래 비용 등에 주의를 기울여야 한다. 올바르게 사용되면 이 전략은 라이브 트레이딩에서 매우 수익성이 될 수 있다.


/*backtest
start: 2023-11-02 00:00:00
end: 2023-11-09 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Bullish Divergence Short-term Long Trade Finder", overlay=false)

max_range = 50 
min_range = 5
///pivot_left = 25
pivot_right = 5

//Inputs
src = input(close, title="Source")
rsiBearCondMin = input.int(50, title="RSI Bearish Condition Minimum")
rsiBearCondSellMin = input.int(60, title="RSI Bearish Condition Sell Min")
rsiBullCondMin = input.int(40, title="RSI Bull Condition Minimum")
pivot_left = input.int(25, title="Look Back this many candles")
SellWhenRSI = input.int(75, title="RSI Sell Value")
StopLossPercent = input.int(5, title="Stop loss Percentage")
rsiPeriod = input.int(14, title="RSI Length")
rsiOversold = input.int(30, title="RSI Oversold Level")
rsiOverbought = input.int(70, title="RSI Overbought Level")

//RSI Function/ value 
rsi_value = ta.rsi(src, rsiPeriod)
rsi_hour = request.security(syminfo.tickerid,'60',rsi_value)
rsi_4hour = request.security(syminfo.tickerid,'240',rsi_value)
rsi_Day = request.security(syminfo.tickerid,'D',rsi_value)
plot(rsi_value, title="RSI", linewidth = 2, color = color.black, display =display.all)
hline(50, linestyle = hline.style_dotted)
rsi_ob = hline(70, linestyle=hline.style_dotted)
rsi_os = hline(30, linestyle=hline.style_dotted)
fill(rsi_ob, rsi_os, color.white)
SL_percent = (100-StopLossPercent)/100 

pivot_low_true = na(ta.pivotlow(rsi_value, pivot_left, pivot_right)) ? false : true

//create a function that returns truee/false
confirm_range(x) => 
    bars = ta.barssince(x == true) //counts the number of bars since thee last time condition was true
    min_range <= bars and bars <= max_range // makees sure bars is less than max_range(50) and greater than min_range(5) 


// RSI higher check / low check
RSI_HL_check = rsi_value<rsiBullCondMin and rsi_value > ta.valuewhen(pivot_low_true and rsi_value<rsiBullCondMin, rsi_value,1) and confirm_range(pivot_low_true[1]) 

// price check for lower low
price_ll_check = low < ta.valuewhen(pivot_low_true, low, 1)

bullCond = price_ll_check and RSI_HL_check and pivot_low_true

//pivot_high_true = na(ta.pivothigh(rsi_value, pivot_left, pivot_right))  ? false : true
pivot_high_true = na(ta.pivothigh(rsi_value, pivot_left, pivot_right))   ? false : true

// RSI Lower check / high check ensuring that the RSI dips below 30 to start divergence 
RSI_LH_check = rsi_value < ta.valuewhen(pivot_high_true and rsi_value>rsiBearCondMin, rsi_value,1) and confirm_range(pivot_high_true[1]) //and rsi_value[pivot_right] >= 65

// price check for lower low
price_hh_check = high > ta.valuewhen(pivot_high_true, high, 1)

bearCond = price_hh_check and RSI_LH_check and pivot_high_true and rsi_value[3] > rsiBearCondSellMin

plot(pivot_low_true ? rsi_value : na, offset=-5, linewidth=3, color=(bullCond ? color.green : color.new(color.white, 100)))

plotshape(bullCond ? rsi_value : na , text = "BUY", style =  shape.labelup, location = location.absolute, color = color.green, offset =0, textcolor = color.white )

plot(pivot_low_true ? rsi_value : na, offset=-5, linewidth=3, color=(bearCond ? color.red : color.new(color.white, 100)))

plotshape(bearCond ? rsi_value : na , text = "Sell", style =  shape.labelup, location = location.absolute, color = color.red, offset =0, textcolor = color.white )
//[bbUpperBand, bbMiddleBand, bbLowerBand] = ta.bb(src, bbPeriod, bbDev)

//Entry Condition
longCondition = false

//bullEntry = bullCond and RSI_HL_check and confirm_range(pivot_low_true[1])
if bullCond and close < ta.valuewhen(pivot_low_true, low, 1) and rsi_hour <40 ///and rsi_4hour<40 //and rsi_Day<50
    strategy.entry("Long", strategy.long)
    
//Exit Condition
if (strategy.position_size > 0 and close < strategy.position_avg_price*SL_percent)
    strategy.close("Long")
if (strategy.position_size > 0 and (rsi_value > SellWhenRSI or bearCond))
    strategy.close("Long")


더 많은