CCI+RSI+KC 트렌드 필터링 롱앤숏 양방향 트레이딩 전략

CCI RSI KC SMA EMA SMMA CMA TMA
생성 날짜: 2024-05-15 16:56:03 마지막으로 수정됨: 2024-05-15 16:56:03
복사: 1 클릭수: 671
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

CCI+RSI+KC 트렌드 필터링 롱앤숏 양방향 트레이딩 전략

개요

이 전략은 CCI, RSI 및 켄터커널 ((KC) 의 세 가지 기술 지표를 사용하여 트렌드 필터와 결합하여 AUDNZD 및 GBPNZD 통화 쌍에서 다방면 양방향 거래를 구현합니다. 이 전략은 CCI와 RSI를 통해 과매매 과매매 상황을 판단하고, KC는 중지 손실의 기준으로 사용하며, 이동 평균을 트렌드 필터로 사용하며, 순조로운 상황에서 포지션 개시 작업을 수행합니다. 이 전략은 지난 5 년의 역사적 데이터에 대한 재검사를 수행하여 안정적인 수익을 얻었습니다.

전략 원칙

  1. CCI, RSI, KC 지표들을 계산한다. KC 상반선은 중선으로 ATR을 더하고, 하반선은 중선으로 ATR을 빼한다.
  2. 입력 매개 변수에 따라 이동 평균 유형을 선택하십시오 (SMA, EMA, SMMA, CMA 또는 TMA) 및 트렌드 필터링 방법을 선택하십시오 (off, positive 또는 reverse).
  3. 다중 상점 개시 조건: 더 많은 것을 허용, CCI <오버셀라인, 클로즈 가격 50 주기 평균*현재 1개 이상의 포지션이 없습니다.
  4. 공백점 포지션 개시 조건: 공백을 허용, CCI> 과잉 구매 라인, 클로즈 가격> KC 경주, RSI> 과잉 구매 라인, 거래량> 50 주기 평균*현재 공백된 포지션
  5. 다수표 평점 조건: CCI>0 ᆞ 공백표 평점 조건: CCI ᆞ
  6. 포지션 개설 시에는 알람이 켜지고, 포지션 평준화 시에도 알람이 켜진다.

전략적 이점

  1. 여러 지표와 결합하여 통합 판단을 통해 신호의 정확성을 향상시킵니다.
  2. 트렌드 필터링을 통해 시장의 흐름에 따라 유연하게 조정할 수 있습니다.
  3. 이동 평균 유형은 선택 가능하며, 시장의 특성에 따라 달라진다.
  4. 오랜 기간 동안의 역사 데이터 검증, 안정성이 좋으며 장기간 사용하기에 적합하다.
  5. 두방향 거래, 다양한 상황에 적응, 더 많은 수익을 얻을 수 있는 기회.
  6. 자동화 수준이 높고, 인적 개입이 필요없고, 시간과 노력을 절약할 수 있습니다.

전략적 위험

  1. 기존의 스톱 스톱이 없어 극단적인 상황에서는 더 큰 회수가 발생할 수 있다.
  2. 이 경우 거래 비용이 증가할 수 있으며, 주가가 낮아질 수도 있다.
  3. 비교적 짧은 CCI 주기를 사용하면 노이즈 신호가 발생할 수 있다.
  4. 트렌드 필터링은 추세가 불분명하거나 시장의 변동이 증가할 때 제한적입니다.
  5. 고정 포지션은 시장의 변동에 적응할 수 없습니다.

전략 최적화 방향

  1. 모바일 스톱 또는 고정 점수 스톱을 추가하여 단일 거래 위험을 제어하는 것이 고려될 수 있습니다.
  2. RSI와 CCI의 매개 변수는 더 이상 노이즈 신호를 줄이기 위해 최적화 될 수 있습니다.
  3. ATR와 같은 변동률 지표를 도입하여 시장의 변동에 따라 포지션 조정 및 중지하는 것을 고려할 수 있습니다.
  4. 더 많은 통화 쌍을 추가하고, 각각의 품종 특성에 따라 개별적으로 최적화된 파라미터를 추가한다.
  5. 기계 학습과 같은 인공지능 기술을 도입하여 최적화 매개 변수를 자체적으로 조정하는 시도.

요약하다

이 전략은 여러 가지 고전 지표를 채택하고, 트레이딩 뷰에서 작성하고 재검토하는 것이 편리하다. 재검토 효과는 좋지만 실장에서는 위험을 제어하고 매개 변수를 조정하는 데 주의를 기울여야 한다. 먼저 작은 자금을 테스트하고, 경험을 쌓은 후 점차적으로 투자를 늘리는 것이 좋습니다. 기계화도가 높으며, 안정적인 투자자의 장기간 사용에 적합하다.

전략 소스 코드
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('CCI Strategy with Trend Filter AUDNZD, GBPNZD', overlay=true, default_qty_type=strategy.cash, default_qty_value=50000, commission_value=0.0005, slippage=2, initial_capital=10000)

// State variables to ensure one entry per signal
var bool isLongOpen = false
var bool isShortOpen = false

// Input Parameters for allowing long and short trades
allowLong = input(true, title='Allow Long Trades')
allowShort = input(true, title='Allow Short Trades')

// Trend Filter Inputs
maType = input.string(title='MA Type', options=['OFF', 'SMA', 'EMA', 'SMMA', 'CMA', 'TMA'], defval='OFF')
trendFilterMethod = input.string(title='Trend Filter Method', options=['OFF', 'Normal', 'Reversed'], defval='OFF')
maLength = input(14, title='MA Length')

// Other Input Parameters
lengthKC = input(30, title='Keltner Channels Length')
multKC = input(0.7, title='Keltner Channels Multiplier')
lengthCCI = input(5, title='CCI Length')
overboughtCCI = input(75, title='CCI Overbought Level')
oversoldCCI = input(-75, title='CCI Oversold Level')
rsiPeriod = input(30, title='RSI Period')
rsiOverbought = input(60, title='RSI Overbought Level')
rsiOversold = input(60, title='RSI Oversold Level')
volumeMultiplier = input.float(0, title='Volume Multiplier', step=0.1, minval=0)

// Define Moving Averages
var float maValue = na
if maType == 'SMA'
    maValue := ta.sma(close, maLength)
else if maType == 'EMA'
    maValue := ta.ema(close, maLength)
else if maType == 'SMMA'
    float initialSMMA = ta.sma(close, maLength)
    maValue := na(maValue[1]) ? initialSMMA : (maValue[1] * (maLength - 1) + close) / maLength
else if maType == 'CMA'
    float firstSMA = ta.sma(close, maLength)
    float secondSMA = ta.sma(close, maLength)
    maValue := na(maValue[1]) ? firstSMA : (firstSMA + secondSMA - maValue[1]) / 2
else if maType == 'TMA'
    maValue := ta.sma(ta.sma(close, math.round(maLength / 2)), math.round(maLength / 2) + 1)

// Entry Conditions with Trend Filter
longCondition = allowLong and (trendFilterMethod == 'OFF' or trendFilterMethod == 'Normal' and close > maValue or trendFilterMethod == 'Reversed' and close < maValue)
shortCondition = allowShort and (trendFilterMethod == 'OFF' or trendFilterMethod == 'Normal' and close < maValue or trendFilterMethod == 'Reversed' and close > maValue)

// Keltner Channels
typicalPrice = hlc3
middleLine = ta.sma(typicalPrice, lengthKC)
range_1 = multKC * ta.atr(lengthKC)
upperChannel = middleLine + range_1
lowerChannel = middleLine - range_1

// CCI
cci = ta.cci(close, lengthCCI)

// RSI
rsi = ta.rsi(close, rsiPeriod)

// Volume
volCondition = volume > ta.sma(volume, 50) * volumeMultiplier

// Combined Entry Conditions with Trend Filter and state check
longCondition := longCondition and cci < oversoldCCI and low < lowerChannel and rsi < rsiOversold and volCondition and not isLongOpen
shortCondition := shortCondition and cci > overboughtCCI and high > upperChannel and rsi > rsiOverbought and volCondition and not isShortOpen

// Execute orders at the open of the new bar after conditions are met
if longCondition
    strategy.entry('Long', strategy.long)
    alert('LicenseID,buy,AUDNZD,risk=1')
    isLongOpen := true
if shortCondition
    strategy.entry('Short', strategy.short)
    alert('LicenseID,sell,AUDNZD,risk=1')
    isShortOpen := true

// Exit Conditions and Alerts
longExitCondition = cci > 0
shortExitCondition = cci < 0
if (longExitCondition and isLongOpen)
    strategy.close('Long')
    alert('LiceneseID,closelong,AUDNZD')
    isLongOpen := false
if (shortExitCondition and isShortOpen)
    strategy.close('Short')
    alert('LicenseID,closeshort,AUDNZD')
    isShortOpen := false

// Plotting
plot(upperChannel, color=color.new(color.red, 0), linewidth=1)
plot(lowerChannel, color=color.new(color.green, 0), linewidth=1)
hline(overboughtCCI, 'Overbought', color=color.red)
hline(oversoldCCI, 'Oversold', color=color.green)