
この戦略は,吊灯出場法則 ((Chandelier Exit),ゼロ遅延移動平均 ((ZLSMA) と相対取引量 ((RVOL) のパルス検出を組み合わせて,完全な取引システムを形成する.吊灯出場法は,実際の波動幅 ((ATR) を介して,ストップロスを動的に調整し,市場の変化に適した位置を保つことができる.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!')