오시슬레이션 돌파구 전략

저자:차오장, 날짜: 2023-10-27 16:32:19
태그:

img

전반적인 설명

이 전략은 래리 코너스의 고전적인 아이디어에 기초하고 있으며, 이중 이동 평균 시스템을 사용하여 시장의 중장기 변동을 포착하고 과잉 구매 또는 과잉 판매되었을 때 이익을 취합니다.

전략 논리

  1. 2주기 RSI를 사용하여 가격이 과판된 영역에 있는지 여부를 결정합니다.

  2. 주요 트렌드 방향을 결정하기 위해 긴 기간 이동 평균 (200 기간) 을 사용하십시오. 가격이 긴 MA보다 높을 때만 오픈 포지션을 고려하십시오.

  3. 가격이 긴 MA보다 높고 RSI가 과잉 판매 라인 이하일 때 시장 가격으로 긴 포지션을 개척합니다.

  4. 가격이 짧은 기간 MA (5 기간) 를 넘어올 때, 수익을 얻기 위해 시장 가격으로 긴 포지션을 닫습니다.

또한 전략은 다음과 같은 구성 가능한 옵션을 제공합니다.

  • RSI 매개 변수: 기간 길이, 과잉 구매/ 과잉 판매 수준.

  • MA 매개 변수: 길고 짧은 기간

  • RSI MA 필터: RSI MA를 추가하여 RSI 변동을 피합니다.

  • 스톱 손실: 스톱 손실을 추가하거나 추가하지 않도록 설정할 수 있습니다.

이점 분석

  1. 이중 MA 시스템은 중장기 동향을 효과적으로 추적할 수 있습니다.

  2. RSI는 격렬한 변동 중에 가장 좋은 출입 시기를 놓치지 않도록 합니다.

  3. 패러미터 최적화에 적합한 유연한 구성

  4. 돌파구 전략, 신호를 놓칠 확률은 없습니다.

위험 분석

  1. 이중 MA 전략은 매개 변수에 민감하며 최상의 성능을 얻기 위해 최적화를 필요로 합니다.

  2. 스톱 로즈가 없으면 손실이 증가할 위험이 있습니다. 조심스러운 포지션 사이즈가 필요합니다.

  3. 가짜 브레이크업은 변동 시장에서 손실을 초래합니다. MA 기간을 최적화하거나 다른 필터를 추가하는 것을 고려하십시오.

  4. 백테스트 과도한 적합성 위험. 시장과 기간에 걸쳐 검증을 필요로 합니다.

최적화 방향

  1. RSI와 MA 매개 변수 조합을 테스트하고 최적화하여 최적을 찾습니다.

  2. 잘못된 신호를 줄이기 위해 부피 스파이크 같은 추가 입력 필터를 테스트합니다.

  3. 단일 거래 손실을 제어하기 위해 후속 스톱 손실을 추가합니다. 전체 수익성에 미치는 영향을 평가하십시오.

  4. 최적을 찾기 위해 다른 보유 기간의 영향을 평가합니다.

  5. 매일처럼 더 긴 시간 내에 견고함을 테스트합니다.

요약

이 전략은 두 번째 MA 트렌드 추적과 RSI 과잉 구매 / 과잉 판매를 결합하여 전형적인 브레이크아웃 시스템을 형성합니다. 매개 변수 최적화, 엄격한 리스크 관리 및 안정성 검증으로 강력한 수치 거래 도구가 될 수 있습니다. 그러나 거래자는 백테스트 과잉 적합성에 주의하고 변화하는 시장 조건에 적응하기 위해 전략을 계속 개선해야합니다.


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

//@version=3
strategy("RSI Strategy", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

//Starter Parameters

length = input(title="RSI Lenght", defval=2)
overBoughtRSI = input(title="OverBought Level for RSI",  defval=10)
shortLength = input(title="Short MA Length",  defval=5)
longLength = input(title="Long MA Length",  defval=200)

RuleMRSI=input(title="RSI Moving Average Filter", defval= true)
lengthmrsi=input(title="RSI Moving Average Length",  defval=4)
overBoughtMRSI=input(title="OverBought Level for the Moving Average of the RSI",  defval=30)

Rulestop=input(title="Apply Stop Loss", defval=false)
stop_percentual=input(title="% Stop Loss",  defval=10)

//RSI

vrsi = rsi(close, length)

//Moving Averages

longma = sma(close,longLength)
shortma = sma(close,shortLength)
mrsi=sma(vrsi,lengthmrsi)

//Stop Loss

stop_level = strategy.position_avg_price*((100-stop_percentual)/100)

//Backtest Period
testStartYear = input(2009, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

testPeriod() => true
    
//Strategy

if testPeriod() and (not na(vrsi))
    if  (RuleMRSI==false) and (Rulestop==false)
        if (vrsi<overBoughtRSI) and (close>longma)
            strategy.entry("RsiLE", strategy.long , comment="Open")
        if (close>shortma)
            strategy.close_all()

    if (RuleMRSI==true) and (Rulestop==false)
        if (vrsi<overBoughtRSI) and (close>longma) and (mrsi<overBoughtMRSI)
            strategy.entry("RsiLE", strategy.long , comment="Open")
        if (close>shortma)
            strategy.close_all()

    if (RuleMRSI==false) and (Rulestop==true)
        if (vrsi<overBoughtRSI) and (close>longma)
            strategy.entry("RsiLE", strategy.long , comment="Open")
            strategy.exit("RsiLE", stop = stop_level)
        if (close>shortma)
            strategy.close_all()

    if (RuleMRSI==true) and (Rulestop==true)
        if (vrsi<overBoughtRSI) and (close>longma) and (mrsi<overBoughtMRSI)
            strategy.entry("RsiLE", strategy.long , comment="Open")
            strategy.exit("RsiLE", stop = stop_level)
        if (close>shortma)
            strategy.close_all()

더 많은