이중 양상 거래 시스템

저자:차오장, 날짜: 2024-02-26 14:30:54
태그:

img

이 전략은 CCI 지표, RSI 지표 및 두 이동 평균을 복합 거래 시스템으로 결합합니다. 일부 소음을 필터링하기 위해 엔트리에 대한 확인을 추가하기 위해 RSI 크로스오버를 사용하여 기존 트렌드를 캡처 할 수 있습니다.

전략 원칙

이 전략은 주로 트렌드 방향을 결정하기 위해 CCI 지표를 사용합니다. CCI 가치는 100 이상으로 상승 시장을 나타내고, -100 이하는 하향 시장을 나타냅니다. 시스템은 트렌드 방향을 결정하는 데 도움이되는 두 개의 이동 평균 크로스오버를 사용합니다. 빠른 이동 평균이 느린 이동 평균을 넘을 때 구매 신호이며 판매 신호는 반대로합니다.

상승세 또는 하락세 트렌드를 결정한 후, 시스템은 진입 검증으로 서로 다른 매개 변수 길이의 두 RSI의 크로스오버를 사용합니다. 예를 들어, 황소 시장에서 단기 RSI가 장기기 RSI를 넘으면 최종 구매 신호입니다. 이 디자인은 주로 트렌드 중에 단기 수정으로 인해 발생하는 잘못된 거래를 피하기 위해 잡음을 필터링합니다.

이 전략은 지정된 거래 세션 동안만 포지션을 열고, 오버나이트 위험을 피하기 위해 폐쇄 15 분 전에 모든 포지션을 적극적으로 닫습니다. 포지션을 열면 수익을 잠금하기 위해 트레일링 스톱이 사용됩니다.

이점 분석

  • 추세 판단과 지표 교차를 결합하면 추세를 효과적으로 식별하고 정확한 항목을 위해 소음을 필터링 할 수 있습니다.
  • 트레일링 스톱을 사용하여 위험을 적극적으로 제어하면 플래시 충돌로 인해 중단되는 것을 피합니다.
  • 특정 거래 세션 중만 포지션을 개설하면 오버나이트 격차 위험을 피할 수 있습니다.
  • 조정 가능한 RSI 매개 변수는 다양한 시장 환경에 유연하게 적응할 수 있습니다.

위험 분석

  • CCI는 비정상적으로 변동적인 시장에서 낮은 성과를 보이고 있습니다.
  • 이중 RSI 크로스 조건은 상대적으로 엄격하며 잠재적으로 몇 가지 기회를 놓치고 있습니다.
  • 후속 정지는 너무 주관적일 수 있습니다. 매개 변수 최적화를 필요로 합니다.
  • 특정 거래 세션에서는 주요 한밤중 뉴스 격차가 빠질 수 있습니다.

최적화 제안

  • 최적의 설정을 찾기 위해 다른 CCI 매개 변수 조합을 테스트합니다.
  • RSI 교차 조건을 제거하고 CCI를 기반으로 직접 입력하는 테스트
  • 역 테스트 및 최적화 후속 정지 매개 변수를 최적의 설정을 찾기
  • 강제 포지션 폐쇄 논리를 제거하고 대신 수익을 극대화하기 위해 포지션 동안 후속 중지로 수익을 추적

요약

이 전략은 위험을 제어하는 동시에 신호 유효성을 보장하기 위해 트렌드 결정과 지표 크로스오버 검증을 포괄적으로 고려합니다. 매개 변수 최적화 및 논리 조정을 통해 전략은 수익 기회를 확대하고 놓친 기회를 줄이는 잠재력을 가지고 있습니다. 이것은 매우 유망한 거래 개념입니다.


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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rwestbrookjr

//@version=5
strategy("EMA with RSI Cross Strategy", overlay=true)

//EMA
fastLen = input(title='Fast EMA Length', defval=9)
slowLen = input(title='Slow EMA Length', defval=20)

fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)

fema = plot(fastEMA, title='FastEMA', color=color.new(color.green, 0), linewidth=1, style=plot.style_line)
sema = plot(slowEMA, title='SlowEMA', color=color.new(color.red, 0), linewidth=1, style=plot.style_line)

fill(fema, sema, color=fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title='Cloud')

// Bull and Bear Alerts
//Bull = ta.crossover(fastEMA, slowEMA)
Bull = fastEMA > slowEMA
//Bear = ta.crossunder(fastEMA, slowEMA)
Bear = fastEMA < slowEMA

//RSIs
rsiLength1Input = input.int(9, minval=1, title="RSI Length", group="RSI Settings")
rsiSource1Input = input.source(close, "Source", group="RSI Settings")
rsiLength2Input = input.int(20, minval=1, title="RSI Length", group="RSI Settings")
rsiSource2Input = input.source(close, "Source", group="RSI Settings")

up1 = ta.rma(math.max(ta.change(rsiSource1Input), 0), rsiLength1Input)
down1 = ta.rma(-math.min(ta.change(rsiSource1Input), 0), rsiLength1Input)
rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))
up2 = ta.rma(math.max(ta.change(rsiSource2Input), 0), rsiLength2Input)
down2 = ta.rma(-math.min(ta.change(rsiSource2Input), 0), rsiLength2Input)
rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))

//CCI
cciLength = input.int(20, minval=1)
src = input(hlc3, title="Source")
ma = ta.sma(src, cciLength)
cci = (src - ma) / (0.015 * ta.dev(src, cciLength))

//Trail Stop Setup
trstp = input.float(title="Trail Loss($)", minval = 0.0, step = 0.01, defval = 0.5)

longStop = 0.0, shortStop = 0.0

longStop := if Bull
    stopValue = close - trstp
    math.max(stopValue, longStop[1])
else
    0.0

shortStop := if Bear
    stopValue = close + trstp
    math.min(stopValue, shortStop[1])
else
    999999


//Session Setup
open_session=input(defval="0930-1545")
session = time("1", open_session)
validSession=(na(session) ? 0 : 1)

//Trade Signals
longCondition = Bull and cci > 100 and ta.crossover(rsi,rsi2) and validSession
if (longCondition)
    strategy.entry("Long", strategy.long, 1)
    
//longExit = close > strategy.opentrades.entry_price(0) + 1.5 or close < strategy.opentrades.entry_price(0) - 0.75
longExit = close < longStop or not validSession
if (longExit)
    strategy.close("Long")

shortCondition = Bear and cci < 100 and ta.crossunder(rsi,rsi2) and validSession
if (shortCondition)
    strategy.entry("Short", strategy.short, 1)

//shortExit = close < strategy.opentrades.entry_price(0) - 1.5 or close > strategy.opentrades.entry_price(0) + 0.75
shortExit = close > shortStop or not validSession
if (shortExit)
    strategy.close("Short")


더 많은