
この戦略は,ゼロの遅延移動平均とトレンド強度評価に基づく定量取引システムである.これは,伝統的な移動平均の遅延をなくし,波動率チャネルとトレンド強度評価を組み合わせて市場のトレンドを識別し,価格の短期間の波動の機会を捕捉する.この戦略は,2方向の取引モデルを採用し,上昇傾向で多做し,下降傾向で空売りし,リスクを制御するためにストップを設定する.
策略の核心は,ゼロの遅延移動平均を使用して,従来の移動平均の遅れの効果を排除することです.具体的実施方法は,まず,現在の価格と遅れの価格の差を計算し,次にその差を現在の価格と加算し,最後に結果の移動平均を計算することです.同時に,策略は,異なる時間周期の価格の高低を比較してトレンドの強さを量化するためのトレンド強度スコアシステムを導入しています.また,策略は,取引信号を破するためにATRベースのダイナミック波動率チャネルを設定しています.価格が突破し,トレンドの評価が値に達したときに取引信号を触発します.
この戦略は,革新的なゼロ遅延計算方法とトレンド強度評価システムにより,伝統的なトレンド追跡戦略の遅れをうまく解決している.同時に,ダイナミックな変動率チャネルと完善したリスク制御機構の導入により,戦略の安定性と信頼性が向上している.戦略のパラメータ最適化と市場適応性に関して改善の余地があるが,全体的な設計思いつきは明確で,実戦価値のアプリケーションが優れている.
/*backtest
start: 2024-11-14 00:00:00
end: 2025-02-19 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © josephdelvecchio
//@version=6
strategy("Zero Lag Trend Strategy", overlay=true)
// -- Input Parameters --
timeframe = input.timeframe("10", "Timeframe")
zeroLagMovAvg = input.string("ema", "Zero Lag Moving Average", options=["ema", "sma"])
length = input.int(50, "Lookback Period")
volatility_mult = input.float(1.5, "Volatility Multiplier")
loop_start = input.int(1, "Loop Start")
loop_end = input.int(50, "Loop End")
threshold_up = input.int(5, "Threshold Up")
threshold_down = input.int(-5, "Threshold Down")
signalpct = input.float(8, "Signal Percentage")
stoppct = input.float(0, "Stop Percentage")
// -- Helper Variables --
nATR = ta.atr(length)
lag = math.floor((length - 1) / 2)
zl_basis = zeroLagMovAvg == "ema" ? ta.ema(2 * close - close[lag], length) : ta.sma(2 * close - close[lag], length)
volatility = ta.highest(nATR, length * 3) * volatility_mult
// -- Trend Strength Scoring Function --
forloop_analysis(basis_price, loop_start, loop_end) =>
int sum = 0 // Use 'sum' as you did originally, for the +/- logic
for i = loop_start to loop_end
if basis_price > basis_price[i]
sum += 1
else if basis_price < basis_price[i] // Explicitly check for less than
sum -= 1
// If they are equal, do nothing (sum remains unchanged)
sum
score = forloop_analysis(zl_basis, loop_start, loop_end)
// -- Signal Generation --
long_signal = score > threshold_up and close > zl_basis + volatility
short_signal = score < threshold_down and close < zl_basis - volatility
// -- Trend Detection (Ensure One Trade Until Reversal) --
var int trend = na
trend := long_signal ? 1 : short_signal ? -1 : trend[1]
trend_changed = trend != trend[1]
// -- Stop-Loss & Take-Profit --
stop_loss = close * (1 - stoppct / 100)
take_profit = close * (1 + signalpct / 100)
// -- Strategy Orders (Enter Only When Trend Changes) --
if long_signal
strategy.entry("Long", strategy.long)
else if short_signal
strategy.entry("Short", strategy.short)
// -- Strategy Exits --
strategy.exit("Exit Long", from_entry="Long", stop=stop_loss, limit=take_profit)
strategy.exit("Exit Short", from_entry="Short", stop=take_profit, limit=stop_loss)
// -- Visualization --
p_basis = zl_basis
plot(p_basis, title="Zero Lag Line", color=color.blue, linewidth=2)
// -- Buy/Sell Arrows --
plotshape(series=trend_changed and trend == 1, location=location.belowbar, color=color.green, style=shape.triangleup, size=size.large, title="Buy Signal")
plotshape(series=trend_changed and trend == -1, location=location.abovebar, color=color.red, style=shape.triangledown, size=size.large, title="Sell Signal")