ベスト ATR ストップロス マルチプル戦略


作成日: 2024-02-21 14:24:22 最終変更日: 2024-02-21 14:24:22
コピー: 1 クリック数: 943
1
フォロー
1617
フォロワー

ベスト ATR ストップロス マルチプル戦略

概要

最良ATRストップ・ロズ・マルチ戦略は,平均真波幅のマルチを使用してストップ・ポイントを設定し,動的にリスク調整するトレンド追跡戦略である.価格のトレンドが変化したときに,タイムリーにストップして巨額の損失を回避することができる.

戦略原則

この戦略は,まず,急速なSMA周期と遅いSMA周期の単純移動平均を計算し,急速なSMA上で遅いSMAを横切るときは多し,急速なSMAの下に遅いSMAを横切るときは空にする.

入場後,ATRの値をリアルタイムで監視する。ATRは過去一定周期における平均波動幅を表している。この策略はATRの周期長さ (デフォルト14) と倍数 (デフォルト2) を設定する。システムは入場時にATRの値を計算し,その後設定された倍数で止損距離として掛けます。

例えば,入場後にATRが50点,倍数が2に設定された場合,止損距離は100点である.価格がその後100点を超えると止損券がトリガーされる.これは,過大な損失を避けるために,間に合った止損を防ぐことができる.

この戦略は同時にトレンド判断を考慮し,買入シグナルが上昇傾向にマッチした場合にのみ,長期ポジションストップを有効にする.空調シグナルが下降傾向にマッチしたときに有効にする.

ストップラインはグラフに描かれ,リアルタイムで検証できます. ストップ条件が触発されたとき,対応するポジションもシステムで自動的に平衡されます.

優位分析

この戦略の最大の利点は,動的にストップ距離を調整し,市場の変動率の変化に応じて自動でリスクのを修正できるということです.変動率が拡大すると,ストップ距離も拡大し,ストップが突破される確率を減らすのです.低波動市場では,ストップ距離も縮小します.

固定ストップ距離とは対照的に,この方法はトレンドを追跡しながら,単一損失を効果的に制御できる.それは,利益の余地と,リスク管理に注意を払うことを保証する.

さらに,トレンド判断と組み合わせたこのストップは,整合区域の震動による出を減らすことができます.

リスク分析

この戦略の主なリスクは,ポジション保有期間中に価格短線が引き下げられ,ストップ・ロースを引き起こすリスクである.特にATR周期が短すぎると,ストップ・距離が短期変動の影響を完全にフィルターできない.

もう一つのリスクは,急激な状況では,価格跳躍運動は,止損線を直接突破する可能性があるということです.この場合,より大きな止損倍数設定が必要ですが,利益の余地が減少することを意味します.

最後に,この戦略は,夜間取引と前売り取引がATR値に与える影響を考慮していない.これは,戦略が計算したATRデータが開盘または閉盘時に不正確になる可能性がある.

最適化の方向

この戦略は以下の点で最適化できます.

  1. ATRサイクルパラメータを最適化し,異なる市場における最適なパラメータの組み合わせをテストする

  2. 固定倍数と動的変化倍数設定のリターン比

  3. 夜盤と開盤前データを組み合わせてATRを計算し,開盤価格の飛躍の影響を最小限に抑える

  4. ATR条件を設定:ATRが一定のレベルに達した後にのみ有効にすることで,低波動率市場の不必要な止損を回避できます.

  5. より多くのフィルタリング条件を組み込む:例えば,大レベルのトレンド,量能指標などの情報

要約する

最適なATRストップロズ倍数戦略は,ストップロズ距離を動的に調整することで,トレンド追跡とリスク管理の間の効果的なバランスを実現します.固定ストップロズ距離と比較して,利益の余地を確保しながら,単一損失を効果的に制限できます.

もちろん,価格の飛躍,過敏なストップダウンのような潜在的なリスクには注意が必要です. 戦略の安定性や収益率を高めるために,我々は多くのレベルで最適化を続けることができます.

ストラテジーソースコード
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//@author=Daveatt
//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

SystemName = "BEST ATR Stop Multiple Strategy"
TradeId = "BEST"

InitCapital = 100000
InitPosition = 100
InitCommission = 0.075
InitPyramidMax = 1
CalcOnorderFills = true
CalcOnTick = true
DefaultQtyType = strategy.fixed
DefaultQtyValue = strategy.fixed
Precision = 2
Overlay=true


strategy(title=SystemName, shorttitle=SystemName, overlay=Overlay )

fastSMAperiod = input(defval=15, title='Fast SMA', type=input.integer, minval=2, step=1)
slowSMAperiod = input(defval=45, title='Slow SMA', type=input.integer, minval=2, step=1)

src = close
// Calculate moving averages
fastSMA = sma(src, fastSMAperiod)
slowSMA = sma(src, slowSMAperiod)

// Calculate trading conditions
enterLong  = crossover(fastSMA, slowSMA)
enterShort = crossunder(fastSMA, slowSMA)

// trend states
since_buy  = barssince(enterLong)
since_sell = barssince(enterShort)
buy_trend  = since_sell > since_buy
sell_trend = since_sell < since_buy 

is_signal = enterLong or enterShort

// get the entry price
entry_price = valuewhen(enterLong or enterShort, src, 0)

// Plot moving averages
plot(series=fastSMA, color=color.teal)
plot(series=slowSMA, color=color.orange)

// Plot the entries
plotshape(enterLong, style=shape.circle, location=location.belowbar, color=color.green, size=size.small)
plotshape(enterShort, style=shape.circle, location=location.abovebar, color=color.red, size=size.small)



///////////////////////////////
//======[ Trailing STOP ]======//
///////////////////////////////

// use SL?
useSL = input(true, "Use stop Loss")
// ATR multiple Stop
stop_atr_length         = input(14,title="ATR Length", minval=1, type=input.integer)
stop_atr_mult           = input(2,title="ATR Multiple", minval=0.05, step=0.1, type=input.float)

// Global STOP

stop_price = 0.0, stop_price := nz(stop_price[1])

// STOP ATR
var stop_atr      = 0.0
var entry_stop_atr   = 0.0

stop_atr          := nz(atr(stop_atr_length))

if enterLong or enterShort
    entry_stop_atr := stop_atr * stop_atr_mult

// display the ATR value multiple
plotshape(enterLong, title='ATR Long Stop value', style=shape.labelup, 
 location=location.bottom, color=color.green, transp=0, text='', textcolor=color.navy, editable=true, size=size.small, show_last=1, size=size.small)

// var label atr_long_label = na
// var label atr_short_label = na
lapos_y_entry_up = lowest(30)
lapos_y_entry_dn = highest(30)

// text_label = "ATR value: " + tostring(stop_atr, '#.#') + "\n\nATR Multiple value: " + tostring(entry_stop_atr, '#.#')

// if enterLong

//     label.delete(atr_long_label)

//     atr_long_label := label.new(bar_index, lapos_y_entry_up, text=text_label, 
//      xloc=xloc.bar_index, yloc=yloc.price, color=color.green, style=label.style_labelup, textcolor=color.white, 
//      size=size.normal)    

// if enterShort

//     label.delete(atr_short_label)

//     atr_short_label := label.new(bar_index, lapos_y_entry_dn, text=text_label, 
//      xloc=xloc.bar_index, yloc=yloc.price, color=color.red, style=label.style_labeldown, textcolor=color.black, 
//      size=size.normal)    

// Determine trail stop loss prices
longStopPrice = 0.0, shortStopPrice = 0.0

longStopPrice := if useSL and buy_trend
    stopValue = entry_price - entry_stop_atr
else
    0

shortStopPrice := if useSL and sell_trend
    stopValue = entry_price + entry_stop_atr
else
    999999

//////////////////////////////////////////////////////////////////////////////////////////
//*** STOP LOSS HIT CONDITIONS TO BE USED IN ALERTS  ***//
//////////////////////////////////////////////////////////////////////////////////////////

cond_long_stop_loss_hit  = useSL and buy_trend and crossunder(low, longStopPrice[1]) 

cond_short_stop_loss_hit = useSL and sell_trend and crossover(high, shortStopPrice[1]) 


// Plot stop loss values for confirmation
plot(series=useSL and buy_trend and low >= longStopPrice 
 ? longStopPrice : na,
 color=color.fuchsia, style=plot.style_cross,
 linewidth=2, title="Long Trail Stop")

plot(series=useSL and sell_trend and high <= shortStopPrice 
 ? shortStopPrice : na,
 color=color.fuchsia, style=plot.style_cross,
 linewidth=2, title="Short Trail Stop")

close_long  = cond_long_stop_loss_hit
close_short = cond_short_stop_loss_hit

// Submit entry orders
strategy.entry(TradeId + " L", long=true, when=enterLong)
strategy.close(TradeId + " L", when=close_long)

//if (enterShort)
strategy.entry(TradeId + " S", long=false, when=enterShort)
strategy.close(TradeId + " S", when=close_short)