CCI와 EMA에 기반한 스칼핑 전략

저자:차오장, 날짜: 2024-01-31 16:01:21
태그:

img

전반적인 설명

이것은 EMA 지표와 CCI 지표를 결합한 단기 오스실레이션 거래 전략으로, 단기 가격 변동의 기회를 포착하기 위해 시장에서 단기 동향과 과잉 구매/ 과잉 판매 수준을 식별합니다.

전략 논리

이 전략은 주로 10일 EMA, 21일 EMA 및 50일 EMA 라인과 CCI 지표를 사용하여 입시 및 출시 시기를 결정합니다.

구체적인 논리는 다음과 같습니다. 단기 이동 평균 (10일 EMA) 이 중기 이동 평균 (21-일 EMA) 을 넘어서고 단기 이동 평균이 장기 이동 평균 (50일 EMA) 보다 높고 동시에 CCI 지표가 0보다 높을 때, 그것은 길게 갈 상승 신호로 간주됩니다. 단기 이동 평균이 중기 이동 평균보다 낮게 넘어가고 단기 이동 평균이 장기 이동 평균보다 낮고 동시에 CCI 지표가 0 미만일 때, 그것은 짧게 갈 하락 신호로 간주됩니다.

출구 논리는 단기 이동 평균이 중기 이동 평균을 다시 넘을 때 포지션을 닫는 것입니다.

장점

  1. 이동평균 시스템과 CCI 지표를 결합하면 단기 가격 추세와 과잉 구매/ 과잉 판매 수준을 효과적으로 파악할 수 있습니다.

  2. 진입과 출구를 결정하기 위해 이동 평균 크로스오버를 사용하는 것은 간단하고 실용적입니다.

  3. CCI 매개 변수와 사이클 설정은 일부 잘못된 신호를 필터링하기 위해 더 합리적입니다.

  4. 이동 평균의 여러 시간 프레임을 채택하면 오스실레이션 시장에서 더 나은 거래 기회를 얻을 수 있습니다.

위험성

  1. 단기 거래의 큰 변동은 연속적인 스톱 로스로 이어질 수 있습니다.

  2. 잘못된 CCI 매개 변수 설정은 잘못된 신호를 증가시킬 수 있습니다.

  3. 범위와 통합 기간 동안이 전략은 여러 개의 작은 손실을 겪을 수 있습니다.

  4. 단기 빈번한 거래자에게만 적합하며 장기 보유에 적합하지 않습니다.

이에 대응하는 위험 감축 조치는 CCI 매개 변수를 최적화하고, 스톱 로스 위치를 조정하고, 필터 조건을 추가하는 것을 포함한다.

최적화 방향

  1. 매개 변수를 최적화하기 위해 EMA 길이의 다양한 조합을 테스트 할 수 있습니다.

  2. MACD, KDJ 등과 같은 일부 잘못된 신호를 필터링하기 위해 다른 지표 또는 필터 조건을 추가 할 수 있습니다.

  3. 동적 후속 스톱 손실을 사용하여 단일 손실을 제어합니다.

  4. 더 높은 시간 프레임 트렌드 지표를 결합하면 트렌드에 반대되는 거래를 피할 수 있습니다.

결론

전체적으로, 이것은 CCI 지표의 과잉 구매/ 과잉 판매 상태와 결합한 이동 평균 라인의 크로스오버를 사용하여 단기 반전 기회를 포착하는 전형적인 단기 오시레이션 전략입니다. 이 전략은 빈번한 단기 거래에 적합하지만 특정 스톱 로스 압력에 견딜 필요가 있습니다. 전략의 안정성과 수익성은 매개 변수 최적화 및 필터 조건을 추가함으로써 더욱 향상 될 수 있습니다.


/*backtest
start: 2023-12-31 00:00:00
end: 2024-01-30 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
//study(title="Strat CCI EMA scalping", shorttitle="EMA-CCI-strat", overlay=true)
strategy("Strat CCI EMA scalping", shorttitle="EMA-CCI-strat", overlay=true)

exponential = input(true, title="Exponential MA")

// the risk management inputs
inpTakeProfit   = input(defval = 1000, title = "Take Profit", minval = 0)
inpStopLoss     = input(defval = 200, title = "Stop Loss", minval = 0)
inpTrailStop    = input(defval = 200, title = "Trailing Stop Loss", minval = 0)
inpTrailOffset  = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0)

// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit   = inpTakeProfit  >= 1 ? inpTakeProfit  : na
useStopLoss     = inpStopLoss    >= 1 ? inpStopLoss    : na
useTrailStop    = inpTrailStop   >= 1 ? inpTrailStop   : na
useTrailOffset  = inpTrailOffset >= 1 ? inpTrailOffset : na

src = close

ma10 = exponential ? ema(src, 10) : sma(src, 10)
ma21 = exponential ? ema(src, 21) : sma(src, 21)
ma50 = exponential ? ema(src, 50) : sma(src, 50)

xCCI = cci(close, 200)

//buy_cond = cross(ma21, ma50) and ma10 > ma21 and (xCCI > 0)
//sell_cond = cross(ma21, ma50) and ma10 < ma21  and (xCCI < 0)

buy_cond = ma10 > ma21 and ma10 > ma50 and xCCI > 0
sell_cond = ma10 < ma21 and ma10 < ma50 and xCCI < 0



// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => buy_cond
exitLong() => ma10 < ma21
strategy.entry(id = "Long", long = true, when = enterLong()) // use function or simple condition to decide when to get in
strategy.close(id = "Long", when = exitLong()) // ...and when to get out
// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => sell_cond
exitShort() => ma10 > ma21
strategy.entry(id = "Short", long = false, when = enterShort())
strategy.close(id = "Short", when = exitShort())

// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
//strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
//strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)




//longCondition = buy_cond
//if(longCondition)
//    strategy.entry("Long", strategy.long)
//    strategy.exit("Close Long", "Long", when = exitLong())
    
//shortCondition = sell_cond
//if(shortCondition)
//    strategy.entry("Short", strategy.short)
//    strategy.exit("Close Short", "Short",  when = exitShort())

//plotshape(buy_cond, style=shape.flag, color=green, size=size.normal)
//plotshape(sell_cond, style=shape.flag, color=red, size=size.normal)

c1 = buy_cond==1 ? lime : sell_cond==1 ? red : #a3a3a3 // color

plot( ma10, color=red, style=line, title="10", linewidth=1)
plot( ma21, color=orange, style=line, title="21", linewidth=1)
plot( ma50, color=c1, style=line, title="50", linewidth=3)

//alertcondition(buy_cond, title = "Buy Condition", message = "Buy Condition Alert")
//alertcondition(sell_cond, title = "Sell Condition", message = "Sell Condition Alert")

더 많은