적응형 듀얼 인디케이터 크로스오버 지능형 타이밍 트레이딩 전략

RSI CCI EMA TIMEFRAME THRESHOLD
생성 날짜: 2025-02-19 10:56:59 마지막으로 수정됨: 2025-02-19 10:56:59
복사: 2 클릭수: 435
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

적응형 듀얼 인디케이터 크로스오버 지능형 타이밍 트레이딩 전략

개요

이것은 RSI와 CCI 이중 기술 지표에 기반한 자기 적응 거래 전략이다. 이 전략은 RSI와 CCI 지표의 교차 상태를 각기 다른 시간 주기에서 모니터링하여 EMA 수평선 추세와 결합하여 완전한 거래 시스템을 구축한다. 이 전략은 자기 적응성이 강하고 신호 안정성이 강한 특징을 가지고 있으며 시장의 과매매 기회를 효과적으로 포착할 수 있다.

전략 원칙

이 전략의 핵심 논리는 다음과 같습니다.

  1. 시간 주기 자율: 다른 시간 주기 ((1분에서 4시간) 에 따라 RSI와 CCI의 파라미터 설정을 동적으로 조정한다.
  2. 이중 지표 확인: RSI (대비적으로 강한 지표) 와 CCI (진행 지표) 의 조합을 사용하여 거래 신호를 필터링하십시오. RSI와 CCI가 특정 조건을 동시에 충족하면 거래 신호가 발생합니다.
  3. 신호 지속성 검증: 최소 지속 시간 (stayTimeFrames) 을 설정하여 신호의 안정성을 보장한다.
  4. 동적 스톱 스톱 손실: 입구시 RSI 및 CCI 수준에 따라 동적으로 설정된 스톱 스톱 손실 지점.
  5. 트렌드 확인: 200주기 EMA를 트렌드 참조로 사용한다.

전략적 이점

  1. 자기 적응력: 전략은 다른 시간 주기에 따라 자동으로 매개 변수를 조정할 수 있어 적응력이 강하다.
  2. 신호 신뢰성: 이중 기술 지표의 교차 확인을 통해 신호의 신뢰성이 크게 향상되었다.
  3. 리스크 관리가 완성된: 동적 스톱 스톱 손실 메커니즘을 적용하여 리스크를 효과적으로 제어할 수 있다.
  4. 운영 규칙이 명확하다: 입출입 조건이 명확하고, 실제 운영에 편리하다.
  5. 확장성: 정책 프레임워크는 필요에 따라 새로운 필터링 조건을 추가할 수 있도록 유연합니다.

전략적 위험

  1. 매개 변수 감수성: 다른 시장 환경에서 최적 매개 변수가 다를 수 있다.
  2. 수평 변동 위험: 시장의 변동 동안 잘못된 신호가 발생할 수 있습니다.
  3. 슬라이드 포인트 효과: 하이프렌크 트레이딩은 슬라이드 포인트 효과에 직면할 수 있다.
  4. 신호 지연: 복수의 확인 메커니즘으로 인해 입국 시기가 약간 지연될 수 있다.
  5. 시장 환경 의존성: 강세를 보이는 시장에서 경기력이 불안정한 시장보다 우수할 수 있다.

전략 최적화 방향

  1. 매개 변수 적응: 매개 변수 최적화 메커니즘을 도입하여 시장 상황에 따라 매개 변수를 동적으로 조정할 수 있다.
  2. 시장 환경 인식: 시장 환경 인식 모듈을 추가하여 다른 시장 상태에서 다른 거래 전략을 사용합니다.
  3. 변동률 적응: 변동률 지표를 도입하고 변동률 크기에 따라 중지 손실 파라미터를 조정한다.
  4. 신호 필터링: 가짜 신호를 필터링하기 위해 더 많은 기술 지표와 형상 인식을 추가하십시오.
  5. 위험 관리: 재원 관리 프로그램을 개선하고, 지분 보유 시간 및 지점 통제를 늘립니다.

요약하다

이 전략은 RSI와 CCI 지표의 장점을 결합하여 안정적인 거래 시스템을 구축한다. 전략의 자율적 특성과 완벽한 위험 제어 메커니즘은 좋은 실용성을 갖는다. 지속적인 최적화와 개선으로 전략은 실제 거래에서 더 나은 성능을 기대한다. 거래자는 실제 사용 전에 충분한 피드백과 변수 최적화를 수행하는 것이 좋습니다.

전략 소스 코드
/*backtest
start: 2025-01-19 00:00:00
end: 2025-02-18 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy("RSI & CCI Strategy with Alerts", overlay=true)

// Detect current chart timeframe
tf = timeframe.period

// Define settings for different timeframes
rsiLength = tf == "1" ? 30 : tf == "5" ? 30 : tf == "15" ? 30 : tf == "30" ? 30 : 30  // Default
cciLength = tf == "1" ? 15 : tf == "5" ? 20 : tf == "15" ? 20 : tf == "30" ? 20 : 20  // Default
cciBuyThreshold = tf == "1" ? -100 : tf == "5" ? -100 : tf == "15" ? -100 : tf == "30" ? -100 : -100
cciSellThreshold = tf == "1" ? 100 : tf == "5" ? 100 : tf == "15" ? 100 : tf == "30" ? 100 : 100  // Default
stayTimeFrames = tf == "1" ? 1 : tf == "5" ? 1 : tf == "15" ? 1 : tf == "30" ? 1 : tf == "240" ? 1 : 2  // Default
stayTimeFramesOver =tf == "1" ? 1 : tf == "5" ? 2 : tf == "15" ? 2 : tf == "30" ? 3 : 2 // Default

// Calculate RSI & CCI
rsi = ta.rsi(close, rsiLength)
rsiOver = ta.rsi(close, 14)
cci = ta.cci(close, cciLength)

// EMA 50
ema200 = ta.ema(close, 200)
plot(ema200, color=color.rgb(255, 255, 255), linewidth=2, title="EMA 200")

// CCI candle threshold tracking
var int cciEntryTimeLong = na
var int cciEntryTimeShort = na

// Store entry time when CCI enters the zone
if (cci < cciBuyThreshold)
    if na(cciEntryTimeLong)
        cciEntryTimeLong := bar_index
else
    cciEntryTimeLong := na

if (cci > cciSellThreshold)
    if na(cciEntryTimeShort)
        cciEntryTimeShort := bar_index
else
    cciEntryTimeShort := na

// Confirming CCI has stayed in the threshold for required bars
cciStayedBelowNeg100 = not na(cciEntryTimeLong) and (bar_index - cciEntryTimeLong >= stayTimeFrames) and rsi >= 53
cciStayedAbove100 = not na(cciEntryTimeShort) and (bar_index - cciEntryTimeShort >= stayTimeFrames) and rsi <= 47


// CCI & RSI candle threshold tracking for Buy Over and Sell Over signals
var int buyOverEntryTime = na
var int sellOverEntryTime = na

// Track entry time when RSI and CCI conditions are met
if (rsiOver <= 31 and cci <= -120)
    if na(buyOverEntryTime)
        buyOverEntryTime := bar_index
else
    buyOverEntryTime := na

if (rsiOver >= 69 and cci >= 120)
    if na(sellOverEntryTime)
        sellOverEntryTime := bar_index
else
    sellOverEntryTime := na

// Confirm that conditions are met for the required stayTimeFrames
buyOverCondition = not na(buyOverEntryTime) and (bar_index - buyOverEntryTime >= stayTimeFramesOver)
sellOverCondition = not na(sellOverEntryTime) and (bar_index - sellOverEntryTime <= stayTimeFramesOver)

//Buy and sell for over bought or sell 
conditionOverBuy = buyOverCondition
conditionOverSell = sellOverCondition

// Buy and sell conditions
buyCondition = cciStayedBelowNeg100
sellCondition = cciStayedAbove100

// // Track open positions
var bool isLongOpen = false
var bool isShortOpen = false

// // Strategy logic for backtesting
// if (buyCondition and not isLongOpen)
//     strategy.entry("Long", strategy.long)
//     isLongOpen := true
//     isShortOpen := false

// if (sellCondition and not isShortOpen)
//     strategy.entry("Short", strategy.short)
//     isShortOpen := true
//     isLongOpen := false

// // Close positions based on EMA 50
// if (isLongOpen and exitLongCondition)
//     strategy.close("Long")
//     isLongOpen := false

// if (isShortOpen and exitShortCondition)
//     strategy.close("Short")
//     isShortOpen := false



// Track RSI at position entry
var float entryRSILong = na
var float entryRSIShort = na

// Track CCI at position entry
var float entryCCILong = na
var float entryCCIShort = na

if (buyOverCondition and not isLongOpen)
    strategy.entry("Long", strategy.long)
    entryRSILong := rsi  // Store RSI at entry
    entryCCILong := cci
    isLongOpen := true
    isShortOpen := false

if (sellOverCondition and not isShortOpen)
    strategy.entry("Short", strategy.short)
    entryRSIShort := rsi  // Store RSI at entry
    entryCCIShort := cci  // Stpre CCI at entry
    isShortOpen := true
    isLongOpen := false

exitLongRSICondition = isLongOpen and not na(entryRSILong) and rsi >= (entryRSILong + 12)  or rsi <= (entryRSILong -8)
exitShortRSICondition = isShortOpen and not na(entryRSIShort) and rsi <= (entryRSIShort - 12)  or rsi >= (entryRSIShort +8)

exitLongCCICondition = isLongOpen and not na(entryCCILong) and cci <= (entryCCILong -100)
exitShortCCICondition = isShortOpen and not na(entryCCIShort) and cci >= (entryCCIShort +100)

// Close positions based on EMA 50 or RSI change
if (isLongOpen and (exitLongRSICondition) or (exitLongCCICondition))
    strategy.close("Long")
    isLongOpen := false
    entryRSILong := na
    entryCCILong := na
    isLongOpen := false

if (isShortOpen and (exitShortRSICondition) or (exitShortCCICondition))
    strategy.close("Short")
    isShortOpen := false
    entryRSIShort := na
    entryCCIShort := na
    isShortOpen := false



// Plot buy and sell signals
plotshape(buyCondition, style=shape.labelup, location=location.belowbar, color=color.green, size=size.large, title="Buy Signal", text="BUY")
plotshape(sellCondition, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.large, title="Sell Signal", text="SELL")

//Plot buy and sell OverBought
plotshape(conditionOverBuy, style=shape.labelup, location=location.belowbar, color=color.rgb(255, 238, 0), size=size.large, title="OverBuy Signal", text="Over Sell")
plotshape(conditionOverSell, style=shape.labeldown, location=location.abovebar, color=color.rgb(186, 40, 223), size=size.large, title="OverSell Signal", text="Over Buy")

// Alerts
alertcondition(buyCondition, title="Buy Alert", message="Buy Signal Triggered")
alertcondition(sellCondition, title="Sell Alert", message="Sell Signal Triggered")