거래 전략에 따른 가격 격차와 추세

저자:차오장, 날짜: 2023-10-25 18:02:11
태그:

img

전반적인 설명

이 전략은 CCI 지표와 모멘텀 지표를 RSI 지표와 결합하여 시장 트렌드를 식별하고 과잉 구매 / 과잉 판매 구역에 격차가 나타나면 입력합니다. 또한 트렌드와 평균 반전 범위를 인식하기 위해 볼링거 밴드를 사용합니다. 이 전략은 파업과 인기를 효과적으로 식별하고, 트렌드 시작에 일찍 들어가, 매개 변수를 조정함으로써 다른 제품에 적응할 수 있습니다.

전략 논리

첫째, 전략은 CCI 지표 또는 0 라인 이상/하를 넘는 모멘텀 지표에 의해 긴 신호와 짧은 신호를 결정합니다. 또한 잘못된 신호를 피하기 위해 RSI가 과잉 구매/ 과잉 판매 구역, 즉 과잉 구매의 경우 65 이상, 과잉 판매의 경우 35 이하에 있어야 합니다.

또한, 전략은 더 신뢰할 수 있는 신호를 보장하기 위해 RSI 상승/하락 오차를 결정할 수 있습니다.

CCI 또는 모멘텀 긴 신호가 트리거되고 RSI가 과판 구역에 있을 때, 전략은 이전 고도와 저도가 모두 볼링거 밴드 평균선 위에 있는지 여부를 확인합니다. 만약 그렇다면 긴 신호가 생성됩니다. 반대로, 짧은 신호가 트리거되고 이전 고도가 평균선 아래에있을 때 짧은 신호가 생성됩니다.

따라서 전략은 트렌드와 오스실레이션 지표를 모두 활용하여 트렌드에 일찍 들어가 평균 반전 범위로 잘못된 브레이크오프를 피합니다. 가격이 볼링거 밴드에서 벗어날 때 전략은 이익을 잠금하고 추가 인하를 방지하기 위해 모든 포지션을 닫습니다.

이점 분석

  1. 트렌드 및 오스실레이션 지표를 결합하면 트렌드에 일찍 들어가서 범위 시장에서 불필요한 위치를 피할 수 있습니다.

  2. 가격 격차와 볼링거 밴드 평균을 사용하면 가짜 브레이크오웃을 효과적으로 필터합니다.

  3. 역사적인 RSI를 확인하면 잘못된 거래 신호를 생성하는 것을 피합니다.

  4. 수동 간섭 없이 완전히 자동화 된 거래, 알고리즘 거래에 적합합니다.

  5. 유연한 매개 변수 조정

  6. 손해를 막고 수익을 통제하는 위험을 효과적으로 감수합니다.

위험 분석

  1. 부적절한 볼링거 밴드 매개 변수는 유효하지 않은 평균 회귀 식별을 일으킬 수 있습니다.

  2. 잘못된 지표 매개 변수는 너무 많은 잘못된 신호를 생성할 수 있습니다.

  3. 실패한 브레이크오웃은 가격이 평균 수준으로 떨어지면

  4. 유동성 부족으로 인해 비효율적인 브레이크아웃 거래가 발생할 수 있습니다.

  5. 곡선의 부적절한 적응을 피하기 위해 충분한 역사적 데이터를 보장합니다.

  6. 가짜 브레이크를 피하기 위해 거래 세션에 주의하십시오.

개선 방향

  1. 더 안정적인 평균 반전 범위를 위해 볼링거 밴드 매개 변수를 최적화합니다.

  2. 더 나은 최적화를 위해 다른 제품에서 매개 변수를 테스트합니다.

  3. 위치 크기를 추가하여 너무 큰 단일 위치를 피합니다.

  4. 주로 활동 시간 동안 거래하도록 거래 세션 필터를 추가합니다.

  5. 더 지능적인 신호를 생성하기 위해 기계 학습 모델을 통합합니다.

  6. 전체 시장 추세를 결정하기 위해 더 많은 데이터 소스를 통합하십시오.

  7. 더 많은 지표를 추가하여 강력한 지표 집합을 형성합니다.

결론

이 전략은 트렌드와 오스실레이션 지표를 통합하여 트렌드를 조기에 포착합니다. 볼링거 밴드 평균과 가격 격차를 사용하여 잘못된 브레이크아웃을 효과적으로 피합니다. 유연한 매개 변수는 훌륭한 백테스트 결과로 다른 제품에 적응합니다. 다음 단계는 더 강력한 매개 변수와 모델 앙상블을 최적화하고 장기적으로 일관된 초과 수익을 달성하는 것입니다.


/*backtest
start: 2022-10-18 00:00:00
end: 2023-10-24 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title='BroTheJo Strategy', shorttitle='BTJ', overlay=true)

// Input settings
ccimomCross = input.string('CCI', 'Entry Signal Source', options=['CCI', 'Momentum'])
ccimomLength = input.int(10, minval=1, title='CCI/Momentum Length')
useDivergence = input.bool(false, title='Find Regular Bullish/Bearish Divergence')
rsiOverbought = input.int(65, minval=1, title='RSI Overbought Level')
rsiOversold = input.int(35, minval=1, title='RSI Oversold Level')
rsiLength = input.int(14, minval=1, title='RSI Length')
plotMeanReversion = input.bool(true, 'Plot Mean Reversion Bands on the chart')
emaPeriod = input(200, title='Lookback Period (EMA)')
bandMultiplier = input.float(1.6, title='Outer Bands Multiplier')

// CCI and Momentum calculation
momLength = ccimomCross == 'Momentum' ? ccimomLength : 10
mom = close - close[momLength]
cci = ta.cci(close, ccimomLength)
ccimomCrossUp = ccimomCross == 'Momentum' ? ta.cross(mom, 0) : ta.cross(cci, 0)
ccimomCrossDown = ccimomCross == 'Momentum' ? ta.cross(0, mom) : ta.cross(0, cci)

// RSI calculation
src = close
up = ta.rma(math.max(ta.change(src), 0), rsiLength)
down = ta.rma(-math.min(ta.change(src), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
oversoldAgo = rsi[0] <= rsiOversold or rsi[1] <= rsiOversold or rsi[2] <= rsiOversold or rsi[3] <= rsiOversold
overboughtAgo = rsi[0] >= rsiOverbought or rsi[1] >= rsiOverbought or rsi[2] >= rsiOverbought or rsi[3] >= rsiOverbought

// Regular Divergence Conditions
bullishDivergenceCondition = rsi[0] > rsi[1] and rsi[1] < rsi[2]
bearishDivergenceCondition = rsi[0] < rsi[1] and rsi[1] > rsi[2]

// Mean Reversion Indicator
meanReversion = plotMeanReversion ? ta.ema(close, emaPeriod) : na
stdDev = plotMeanReversion ? ta.stdev(close, emaPeriod) : na
upperBand = plotMeanReversion ? meanReversion + stdDev * bandMultiplier : na
lowerBand = plotMeanReversion ? meanReversion - stdDev * bandMultiplier : na

// Entry Conditions
prevHigh = ta.highest(high, 1)
prevLow = ta.lowest(low, 1)
longEntryCondition = ccimomCrossUp and oversoldAgo and (not useDivergence or bullishDivergenceCondition) and (prevHigh >= meanReversion) and (prevLow >= meanReversion)
shortEntryCondition = ccimomCrossDown and overboughtAgo and (not useDivergence or bearishDivergenceCondition) and (prevHigh <= meanReversion) and (prevLow <= meanReversion)

// Plotting
oldLongEntryCondition = ccimomCrossUp and oversoldAgo and (not useDivergence or bullishDivergenceCondition)
oldShortEntryCondition = ccimomCrossDown and overboughtAgo and (not useDivergence or bearishDivergenceCondition)
plotshape(oldLongEntryCondition, title='BUY', style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(oldShortEntryCondition, title='SELL', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)

// Strategy logic
if (longEntryCondition)
    strategy.entry("Buy", strategy.long)
if (shortEntryCondition)
    strategy.entry("Sell", strategy.short)

// Close all open positions when outside of bands
closeAll = (high >= upperBand) or (low <= lowerBand)

if (closeAll)
    strategy.close_all("Take Profit/Cut Loss")


// Plotting
plot(upperBand, title='Upper Band', color=color.fuchsia, linewidth=1)
plot(meanReversion, title='Mean', color=color.gray, linewidth=1)
plot(lowerBand, title='Lower Band', color=color.blue, linewidth=1)

더 많은