
동적 CCI 돌파 전략은 CCI 지표를 사용하여 과매매 과매매를 식별하는 단선 거래 전략이다. CCI 지표와 WMA 평균을 결합하여, CCI 지표가 과매매 영역에서 부진했을 때 과매매하고, CCI 지표가 과매 영역에서 돌아왔을 때 공백하고, 이익을 얻은 후 퇴출한다.
이 전략은 CCI 지표를 사용하여 시장의 과매매를 판단한다. CCI 지표는 가격 이상 상황을 효과적으로 식별할 수 있다. CCI 지표가 100보다 낮으면 시장 과매매로 간주되며, 100보다 높으면 시장 과매매로 간주된다.
동시에, 전략은 WMA 평균선과 결합하여 트렌드 방향을 판단한다. 종결 가격이 WMA 평균선보다 높을 때만, 다중 신호가 유효하다. 종결 가격이 WMA 평균선보다 낮을 때만, 공백 신호가 유효하다. 이렇게하면 일부 불분명한 거래 신호를 필터링 할 수 있다.
입시 후, 전략은 손실을 방지하는 방법을 사용한다. 세 가지의 선택 가능한 손실 방식이 있다: 고정 전략의 손실, 가격 변동 범위의 손실, ATR의 손실. 너무 많이 할 때, 가격이 스탠드 라인까지 떨어지면 손실이 사라지고, 공백 할 때, 가격이 스탠드 라인까지 올라가면 손실이 사라진다.
이 전략에는 다음과 같은 장점이 있습니다.
이 전략에는 다음과 같은 위험도 있습니다.
위와 같은 위험들에 대한 주요 최적화 방법은 다음과 같습니다.
이 전략은 다음의 몇 가지 측면에서 최적화될 수 있습니다.
CC 지표 변수 최적화: CCI 지표의 주기 변수를 조정하고, 지표 변수를 최적화한다.
손해방식 최적화: 다양한 손해방식을 테스트하여 최적의 손해방식을 선택한다. 손해방식 추적에 추가할 수 있다.
필터 지표 최적화: MACD, RSI 등 다른 지표들을 추가하여, 여러 지표 필터링 시스템을 구축하여, 거짓 신호를 줄인다.
트렌드 판단 최적화: 이동 평균과 같은 트렌드 판단 지표를 추가하여 역동 조작을 피한다.
자동 중지 최적화: 동적 중지 방법을 구축하여 전략이 시장의 변동에 따라 자동 중지 할 수 있습니다.
동적 CCI 돌파 전략은 전체적으로 매우 실용적인 짧은 라인 거래 전략이다. CCI 지표를 사용하여 과매매를 판단하고, 평평한 방향으로 판단하는 방법으로 진입한다. 위험 제어는 중지 손실 방식을 채택한다. 이 전략 신호는 간단하고 명확하며, 쉽게 구현할 수 있으며, 짧은 라인 거래에 적합하다.
/*backtest
start: 2023-02-11 00:00:00
end: 2023-09-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tweakerID
// ---From the "Bitcoin Trading Strategies" book, by David Hanson---
// After testing, works better with an ATR stop instead of the Strategy Stop. This paramater
// can be changed from the strategy Inputs panel.
// "CCI Scalping Strategy
// Recommended Timeframe: 5 minutes
// Indicators: 20 Period CCI, 20 WMA
// Long when: Price closes above 20 WMA and CCI is below -100, enter when CCI crosses above -100.
// Stop: Above 20 WMA"
//@version=4
strategy("CCI Scalping Strat",
overlay=true,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=10000,
commission_value=0.04,
calc_on_every_tick=false,
slippage=0)
direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))
/////////////////////// STRATEGY INPUTS ////////////////////////////////////////
title1=input(true, "-----------------Strategy Inputs-------------------")
i_Stop = input(0, step=.05, title="Strategy Stop Mult")*.01
i_CCI=input(16, title="CCI Length")
i_WMA=input(5, title="WMA Length")
/////////////////////// BACKTESTER /////////////////////////////////////////////
title2=input(true, "-----------------General Inputs-------------------")
// Backtester General Inputs
i_SL=input(true, title="Use Stop Loss and Take Profit")
i_SLType=input(defval="ATR Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])
i_SPL=input(defval=10, title="Swing Point Lookback")
i_PercIncrement=input(defval=2, step=.1, title="Swing Point SL Perc Increment")*0.01
i_ATR = input(14, title="ATR Length")
i_ATRMult = input(10, step=.1, title="ATR Multiple")
i_TPRRR = input(1.5, step=.1, title="Take Profit Risk Reward Ratio")
// Bought and Sold Boolean Signal
bought = strategy.position_size > strategy.position_size[1]
or strategy.position_size < strategy.position_size[1]
// Price Action Stop and Take Profit
LL=(lowest(i_SPL))*(1-i_PercIncrement)
HH=(highest(i_SPL))*(1+i_PercIncrement)
LL_price = valuewhen(bought, LL, 0)
HH_price = valuewhen(bought, HH, 0)
entry_LL_price = strategy.position_size > 0 ? LL_price : na
entry_HH_price = strategy.position_size < 0 ? HH_price : na
tp=strategy.position_avg_price + (strategy.position_avg_price - entry_LL_price)*i_TPRRR
stp=strategy.position_avg_price - (entry_HH_price - strategy.position_avg_price)*i_TPRRR
// ATR Stop
ATR=atr(i_ATR)*i_ATRMult
ATRLong = ohlc4 - ATR
ATRShort = ohlc4 + ATR
ATRLongStop = valuewhen(bought, ATRLong, 0)
ATRShortStop = valuewhen(bought, ATRShort, 0)
LongSL_ATR_price = strategy.position_size > 0 ? ATRLongStop : na
ShortSL_ATR_price = strategy.position_size < 0 ? ATRShortStop : na
ATRtp=strategy.position_avg_price + (strategy.position_avg_price - LongSL_ATR_price)*i_TPRRR
ATRstp=strategy.position_avg_price - (ShortSL_ATR_price - strategy.position_avg_price)*i_TPRRR
/////////////////////// STRATEGY LOGIC /////////////////////////////////////////
//CCI
CCI=cci(close, i_CCI)
//WMA
WMA=wma(close, i_WMA)
//Stops
LongStop=valuewhen(bought, WMA, 0)*(1-i_Stop)
ShortStop=valuewhen(bought, WMA, 0)*(1+i_Stop)
StratTP=strategy.position_avg_price + (strategy.position_avg_price - LongStop)*i_TPRRR
StratSTP=strategy.position_avg_price - (ShortStop - strategy.position_avg_price)*i_TPRRR
BUY = (close > WMA) and crossover(CCI , -100)
SELL = (close < WMA) and crossunder(CCI , 100)
//Trading Inputs
DPR=input(true, "Allow Direct Position Reverse")
reverse=input(false, "Reverse Trades")
// Entries
if reverse
if not DPR
strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)
strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)
else
strategy.entry("long", strategy.long, when=SELL)
strategy.entry("short", strategy.short, when=BUY)
else
if not DPR
strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)
strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)
else
strategy.entry("long", strategy.long, when=BUY)
strategy.entry("short", strategy.short, when=SELL)
SL= i_SLType == "Swing Lo/Hi" ? entry_LL_price : i_SLType == "ATR Stop" ? LongSL_ATR_price : LongStop
SSL= i_SLType == "Swing Lo/Hi" ? entry_HH_price : i_SLType == "ATR Stop" ? ShortSL_ATR_price : ShortStop
TP= i_SLType == "Swing Lo/Hi" ? tp : i_SLType == "ATR Stop" ? ATRtp : StratTP
STP= i_SLType == "Swing Lo/Hi" ? stp : i_SLType == "ATR Stop" ? ATRstp : StratSTP
strategy.exit("TP & SL", "long", limit=TP, stop=SL, when=i_SL)
strategy.exit("TP & SL", "short", limit=STP, stop=SSL, when=i_SL)
/////////////////////// PLOTS //////////////////////////////////////////////////
plot(WMA)
plot(i_SL and strategy.position_size > 0 ? SL : na , title='SL', style=plot.style_cross, color=color.red)
plot(i_SL and strategy.position_size < 0 ? SSL : na , title='SSL', style=plot.style_cross, color=color.red)
plot(i_SL and strategy.position_size > 0 ? TP : na, title='TP', style=plot.style_cross, color=color.green)
plot(i_SL and strategy.position_size < 0 ? STP : na, title='STP', style=plot.style_cross, color=color.green)
// Draw price action setup arrows
plotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar,
color=color.green, title="Bullish Setup", size=size.auto)
plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar,
color=color.red, title="Bearish Setup", size=size.auto)