ダイナミックATR トレイリングストップ損失戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-11 14:24:18
タグ:

img

概要

この戦略は,ATR指標で設計された動的ストップ損失メカニズムに基づいています. 利益の最大化のために効果的なストップ損失を保証しながら,リアルタイムでストップ損失を調整します.

戦略の論理

この戦略は,高速ATR期5と遅いATR期10を使用して,二層ダイナミックトレーリングストップ損失を構築する.価格が有利な方向に動くと,高速層はまずトレーリングストップを活性化してストップ損失を締めくくります.短期的なプルバックがある場合,遅い層ストップ損失は早速ストップアウトを回避することができます.一方,高速と遅い層の間のクロスオーバーは取引信号として機能します.

特に,高速層のストップ損失距離は5期ATRの0.5倍であり,スロー層のストップ損失距離は10期ATRの3倍である.高速層がスロー層の上を突破すると購入信号が生成され,高速層がスロー層を下に突破すると販売信号が生成される.ストップ損失線はリアルタイムで更新され,価格曲線の下にプロットされる.

利点分析

この戦略の最大の利点は,効果的なストップ損失を保証しながら利益を最大化するためにストップ損失ポジションを動的に調整できるということです. 固定ストップ損失距離と比較して,動的なATRストップ損失線は,ストップ損失の発生確率を減らすために市場の変動に基づいて調整することができます.

さらに,二層のATR設計は,ストップ損失の感度をバランスする.速い層は迅速に対応し,遅い層は短期間のノイズをフィルタリングして,早期のストップ損失を回避することができます.

リスク分析

この戦略の主なリスクは,ストップ損失距離の設定が合理的かどうかにある. ATR マルチプリキュアがあまりにも高く設定されている場合,ストップ損失範囲は価格動きに追いつかない. ATR マルチプリキュアが小さすぎると,短期的なノイズによって停止される傾向があります. したがって,パラメータは異なる品種の特徴に応じて調整する必要があります.

さらに,レンジ・バインド市場では,ATR値は小さく,ストップ・ロスはより近いため,ストップ・ロスは頻繁に発生する.したがって,この戦略は一定の波動性を持つ株に適している.

オプティマイゼーションの方向性

ATRサイクルパラメータの異なる組み合わせを試して最適なバランスを見つけることができる.また,市場段階を判断するためのトレンド指標などの他の指標と組み合わせることを検討し,ATR倍数の大きさを動的に調整することができる.

また,ATR指標の代替方法も検討できます.ATRをDKVOL,HRANGE,ATRパーセントなどで置き換えることで,よりよいストップ損失効果が得られます.

概要

この戦略は,過剰なストップ損失を回避しながら利益を最大化するためにATR指標に基づいた二層ダイナミックトレーリングメカニズムを設計する.ストップ損失に対する要求が高くなるユーザーに適しています.この戦略は,最適なストップ損失効果を達成するために,市場および品種特性に応じてパラメータを柔軟に調整できます.


/*backtest
start: 2022-12-04 00:00:00
end: 2023-12-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("ATR Trailing Stop Strategy by ceyhun", overlay=true)

/////////notes////////////////////////////////////////
// This is based on the ATR trailing stop indicator //
// width addition of two levels of stops and        //
// different interpretation.                        //
// This is a fast-reacting system and is better     //
// suited for higher volatility markets             //
//////////////////////////////////////////////////////

SC = input(close, "Source", input.source)

// Fast Trail //
AP1 = input(5, "Fast ATR period", input.integer)  // ATR Period
AF1 = input(0.5, "Fast ATR multiplier", input.float)  // ATR Factor
SL1 = AF1 * atr(AP1)  // Stop Loss
Trail1 = 0.0
Trail1 := iff(SC > nz(Trail1[1], 0) and SC[1] > nz(Trail1[1], 0), max(nz(Trail1[1], 0), SC - SL1), iff(SC < nz(Trail1[1], 0) and SC[1] < nz(Trail1[1], 0), min(nz(Trail1[1], 0), SC + SL1), iff(SC > nz(Trail1[1], 0), SC - SL1, SC + SL1)))

// Slow Trail //
AP2 = input(10, "Slow ATR period", input.integer)  // ATR Period
AF2 = input(3, "Slow ATR multiplier", input.float)  // ATR Factor
SL2 = AF2 * atr(AP2)  // Stop Loss
Trail2 = 0.0
Trail2 := iff(SC > nz(Trail2[1], 0) and SC[1] > nz(Trail2[1], 0), max(nz(Trail2[1], 0), SC - SL2), iff(SC < nz(Trail2[1], 0) and SC[1] < nz(Trail2[1], 0), min(nz(Trail2[1], 0), SC + SL2), iff(SC > nz(Trail2[1], 0), SC - SL2, SC + SL2)))

// Bar color for trade signal //
Green = Trail1 > Trail2 and close > Trail2 and low > Trail2
Blue = Trail1 > Trail2 and close > Trail2 and low < Trail2
Red = Trail2 > Trail1 and close < Trail2 and high < Trail2
Yellow = Trail2 > Trail1 and close < Trail2 and high > Trail2

// Signals //
Bull = barssince(Green) < barssince(Red)

Buy = crossover(Trail1, Trail2)
Sell = crossunder(Trail1, Trail2)

TS1 = plot(Trail1, "Fast Trail", style=plot.style_line, color=Trail1 > Trail2 ? color.blue : color.yellow, linewidth=2, display=display.none)
TS2 = plot(Trail2, "Slow Trail", style=plot.style_line, color=Trail1 > Trail2 ? color.green : color.red, linewidth=2)
fill(TS1, TS2, Bull ? color.new(color.green, 90) : color.new(color.red, 90))

plotcolor = input(true, "Paint color on chart", input.bool)

bcl = iff(plotcolor == 1, Blue ? color.blue : Green ? color.lime : Yellow ? color.yellow : Red ? color.red : color.white, na)
barcolor(bcl)

if Buy
    strategy.entry("Buy", strategy.long, comment="Buy")

if Sell
    strategy.close("Buy")


もっと