
이 전략은 들리어 출구 (Chandelier Exit), 제로 지연 이동 평균 (ZLSMA) 및 상대 거래량 (RVOL) 펄스 검출을 결합하여 하나의 완전한 거래 시스템을 형성한다. 들리어 출구 (Chandelier Exit), 제로 지연 이동 평균 (ZLSMA) 및 상대 거래량 (RVOL) 펄스 검출은 전략이 낮은 변동률의 시장에서 피하는 데 도움을 주고 거래 품질을 향상시킵니다.
ZLSMA-강화형 램프 출구 전략과 거래량 펄스 검출은 트렌드 추적형 전략으로, 동적 스톱로스, 트렌드 판단 및 거래량 펄스 검출을 통해 트렌드 기회를 잡는 동시에 거래 위험을 제어한다. 전략 논리는 명확하고 이해하기 쉽고 구현되지만 실제 응용에서는 특정 시장 특성과 거래 품종과 결합하여 여전히 최적화 및 개선이 필요합니다. 더 많은 신호 확인 지표를 도입하고 출구 조건을 최적화하고 매개 변수를 합리화하고 엄격한 포지션 관리 및 위험 관리를 통해 전략은 안정적이고 효율적인 거래 도구가 될 전망이다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Chandelier Exit Strategy with ZLSMA and Volume Spike Detection", shorttitle="CES with ZLSMA and Volume", overlay=true, process_orders_on_close=true, calc_on_every_tick=false)
// Chandelier Exit Inputs
lengthAtr = input.int(title='ATR Period', defval=1)
mult = input.float(title='ATR Multiplier', step=0.1, defval=2.0)
useClose = input.bool(title='Use Close Price for Extremums', defval=true)
// Calculate ATR
atr = mult * ta.atr(lengthAtr)
// Calculate Long and Short Stops
longStop = (useClose ? ta.highest(close, lengthAtr) : ta.highest(high, lengthAtr)) - atr
shortStop = (useClose ? ta.lowest(close, lengthAtr) : ta.lowest(low, lengthAtr)) + atr
// Update stops based on previous values
longStop := na(longStop[1]) ? longStop : close[1] > longStop[1] ? math.max(longStop, longStop[1]) : longStop
shortStop := na(shortStop[1]) ? shortStop : close[1] < shortStop[1] ? math.min(shortStop, shortStop[1]) : shortStop
// Determine Direction
var int dir = na
dir := na(dir[1]) ? (close > shortStop ? 1 : close < longStop ? -1 : na) : close > shortStop[1] ? 1 : close < longStop[1] ? -1 : dir[1]
// ZLSMA Inputs
lengthZLSMA = input.int(title="ZLSMA Length", defval=50)
offsetZLSMA = input.int(title="ZLSMA Offset", defval=0)
srcZLSMA = input.source(close, title="ZLSMA Source")
// ZLSMA Calculation
lsma = ta.linreg(srcZLSMA, lengthZLSMA, offsetZLSMA)
lsma2 = ta.linreg(lsma, lengthZLSMA, offsetZLSMA)
eq = lsma - lsma2
zlsma = lsma + eq
// Plot ZLSMA
plot(zlsma, title="ZLSMA", color=color.purple, linewidth=3)
// Swing High/Low Calculation
swingHigh = ta.highest(high, 5)
swingLow = ta.lowest(low, 5)
// Relative Volume (RVOL) Calculation
rvolLength = input.int(20, title="RVOL Length")
rvolThreshold = input.float(1.5, title="RVOL Threshold")
avgVolume = ta.sma(volume, rvolLength)
rvol = volume / avgVolume
// Define buy and sell signals based on ZLSMA and Volume Spike
buySignal = (dir == 1 and dir[1] == -1 and close > zlsma and rvol > rvolThreshold)
sellSignal = (dir == -1 and dir[1] == 1 and close < zlsma and rvol > rvolThreshold)
// Define exit conditions based on ZLSMA
exitLongSignal = (close < zlsma)
exitShortSignal = (close > zlsma)
// Strategy Entries and Exits
if (buySignal)
strategy.entry("Long", strategy.long, stop=swingLow)
if (sellSignal)
strategy.entry("Short", strategy.short, stop=swingHigh)
if (exitLongSignal)
strategy.close("Long")
if (exitShortSignal)
strategy.close("Short")
// Alerts
alertcondition(buySignal, title='Alert: CE Buy', message='Chandelier Exit Buy!')
alertcondition(sellSignal, title='Alert: CE Sell', message='Chandelier Exit Sell!')