
이 전략은 단선 진동 거래 전략으로, EMA 평균 지수와 CCI 지수를 결합하여 시장의 단선 추세와 과매매 상태를 식별하여 단선 가격 변동의 기회를 잡습니다.
이 전략은 주로 10일 EMA, 21일 EMA, 50일 EMA의 세 개의 평균선과 CCI 지수를 사용하여 입출장 시간을 판단한다.
그 논리는 다음과 같습니다. 단기평균선 ((10일 EMA) 위가 중기평균선 ((21일 EMA) 을 통과하고 단기평균선이 장기평균선 ((50일 EMA) 보다 높을 때, CCI 지표가 0보다 크면 다단계 신호로 간주하고, 더 많은 일을 한다. 단기평균선이 중기평균선 아래로 통과하고 단기평균선이 장기평균선보다 낮을 때, CCI 지표가 0보다 작으면 공백 신호로 간주하고, 공백을 한다.
평소 위치 논리는 단기 평균선이 중기 평균선을 다시 가로질러 평소 위치한다.
평행선 시스템과 CCI 지표가 결합되어, 단선 가격 변동의 트렌드 방향과 과매매 상태를 효과적으로 식별할 수 있다.
평선 금강과 사다리를 사용하여 엔트리와 엑시스트를 판단하는 것은 간단하고 실용적입니다.
CCI 지표의 파라미터와 주기 설정은 합리적이어서 일부 가짜 신호를 제거할 수 있다.
여러 시간 주기의 평균선으로, 흔들리는 시장에서 더 나은 운용 기회를 얻을 수 있다.
단선 운영의 변동성이 크며, 연속적인 정지 손실이 더 많을 수 있다.
CCI 지표 파라미터를 잘못 설정하면 가짜 신호가 증가할 수 있다.
이 전략은 충격적인 정리 기간 동안 몇 차례의 작은 손실을 초래할 수 있습니다.
짧은 라인을 자주 사용하는 거래자에게만 적합하며, 긴 라인을 보유하는 것은 적합하지 않습니다.
이에 대응하는 위험 대응 방법은 CCI 파라미터를 최적화하고, 스톱 포지션을 조정하고, FILTER 조건을 추가하는 등이다.
다양한 길이의 EMA 평균선 조합을 테스트할 수 있으며, 최적화 매개 변수 △
다른 지표 또는 Filter 조건이 추가되어 일부 가짜 신호를 필터링 할 수 있습니다. 예를 들어 MACD, KDJ 등.
단편적 손실은 동적으로 추적된 스톱로스로 제어할 수 있다.
더 높은 시간 주기 트렌드 지표와 결합하여 역동적인 동작을 피할 수 있다.
이 전략은 전체적으로 전형적인 짧은 라인 흔들림 전략으로, 평준 지표의 금 포크 데드 포크와 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")