スーパートレンド戦略

作者: リン・ハーンチャオチャン開催日:2023年10月13日17時03分55秒
タグ:

概要

スーパートレンド戦略は,平均の真の範囲の計算に基づいたトレンドフォロー戦略である.これはATRを使用してストップ損失ラインを設定し,価格がストップ損失ラインを突破するかどうかを判断してトレンド方向を決定し,それによって取引信号を生成する.

戦略の論理

ストラテジーは,まず,一定の期間における平均真差 (ATR) を計算する.その後,ATR値をスケーリング因数で掛け算して,ロングストップ・ロストラインとショートストップ・ロストラインを計算する.具体的な計算は以下のとおりである:

atr = mult * atr(length)

longStop = hl2 - atr 

shortStop = hl2 + atr

long は ATR を計算する期間で,mult は ATR のスケーリング因数です.

ストップ・ロスの線を計算した後,この戦略は,価格が前のバーのストップ・ロスの線を突破するかどうかを判断し,トレンドの方向性を決定します.

dir := dir == -1 and close > shortStopPrev ? 1 :  
         dir == 1 and close < longStopPrev ? -1 : dir

ロングストップ・ロスの線が切断されると,トレンドは上昇傾向とみなされます.ショートストップ・ロスの線が切断されると,トレンドは下落傾向とみなされます.

トレンド方向の変化に応じて,購入・販売シグナルが生成されます.

buySignal = dir == 1 and dir[1] == -1

sellSignal = dir == -1 and dir[1] == 1 

最後に,買い/売るシグナルが表示されると対応する取引行動が実行されます.

利点

  1. ストップ・ロスの線を計算するために ATR を使用することで,市場のノイズを効果的にフィルタリングし,より信頼性の高いトレンド信号を捉えることができます.

  2. この戦略には,理解し操作しやすいパラメータがほとんどありません. ATR期間と倍数は,異なる市場状況に合わせて調整できます.

  3. ストップ・ロスのラインのブレイクを使用してトレンド方向の変化を決定することは,リスクを効果的に制御し,時間をかけてストップ・ロスをできます.

  4. 異なる取引スタイルに合わせて,長時間のみまたは双方向取引に設定できます.

  5. 任意の時間枠と様々な取引手段で使用できます.

リスク

  1. ATRは,範囲市場では,より高い値に引き上げられ,より広いストップ損失とより多くの誤った信号をもたらす可能性があります.

  2. 最適なパラメータの組み合わせは不確実である.ATR期間と倍数は市場状況に基づいて最適化する必要があります.

  3. 各取引手段の最適な時間枠は不明で,テストする必要がある.

  4. 最適なエントリータイミングは不明で 遅延がある.

  5. 傾向が弱っているとき 市場に入れないリスクがあります

  6. ストップ・ロスのリスクがある.より広範なストップ・ロスは考慮されるかもしれない.

強化

  1. MACD,RSIなどの他の指標は,フィルタリングのために組み込まれ,市場範囲で間違った信号を避けることができます.

  2. 最適なパラメータセットを見つけるために 機械学習や遺伝アルゴリズムを使用できます

  3. 各機器に対してパラメータ最適化を行って,最高のATR期間と倍数を見つけることができます.

  4. ボリューム指標は,より良い入場タイミングを決定し,早期入場を避けるために使用できます.

  5. 市場に入っていないときに ポジションを保持するために ロッキング戦略を使用することを検討します

  6. ストップ・ロスの幅は,トレンド強度指標で緩め,最適化することができます.

結論

スーパートレンド戦略は,価格ブレイクが発生したときにトレンド変化を検出するためにATRから計算されたダイナミックストップ損失ラインを使用する.これは比較的信頼性がありリスク制御されたトレンドフォローシステムです.この戦略は使いやすくて,さまざまな楽器に適用できますが,パラメータとルールは,さまざまな市場でより良いパフォーマンスを実現するために最適化する必要があります.他の技術指標と戦略と組み合わせることで,取引結果がさらに改善できます.一般的に,スーパートレンドは科学的に健全なコンセプトに基づいており,トレーダーによるさらなる研究と適用に値します.


/*backtest
start: 2023-09-12 00:00:00
end: 2023-10-12 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// strategy("SuperTrend Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=1000)

LongOnly = input(title="Long Only ?", type=input.bool, defval=true)
length = input(title="ATR Period", type=input.integer, defval=22)
mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
showLabels = input(title="Show Buy/Sell Labels ?", type=input.bool, defval=true)

////////////////////////////////////////////////////////////////////////////////
// BACKTESTING RANGE

// From Date Inputs
fromDay = input(defval=1, title="From Day", minval=1, maxval=31)
fromMonth = input(defval=1, title="From Month", minval=1, maxval=12)
fromYear = input(defval=2019, title="From Year", minval=1970)

// To Date Inputs
toDay = input(defval=1, title="To Day", minval=1, maxval=31)
toMonth = input(defval=1, title="To Month", minval=1, maxval=12)
toYear = input(defval=2020, title="To Year", minval=1970)

// Calculate start/end date and time condition
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true

////////////////////////////////////////////////////////////////////////////////


atr = mult * atr(length)

longStop = hl2 - atr
longStopPrev = nz(longStop[1], longStop)
longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop

shortStop = hl2 + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop

dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and close > shortStopPrev ? 1 : 
   dir == 1 and close < longStopPrev ? -1 : dir

longColor = color.green
shortColor = color.red


plot(dir == 1 ? longStop : na, title="Long Stop", style=plot.style_linebr, linewidth=2, color=longColor)
buySignal = dir == 1 and dir[1] == -1
plotshape(buySignal ? longStop : na, title="Long Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor, transp=0)
plotshape(buySignal and showLabels ? longStop : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=longColor, textcolor=color.white, transp=0)

plot(dir == 1 ? na : shortStop, title="Short Stop", style=plot.style_linebr, linewidth=2, color=shortColor)
sellSignal = dir == -1 and dir[1] == 1
plotshape(sellSignal ? shortStop : na, title="Short Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor, transp=0)
plotshape(sellSignal and showLabels ? shortStop : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.white, transp=0)

if LongOnly
    if buySignal and time_cond
        strategy.entry("Long", strategy.long, comment="Long")
    
    if(sellSignal and time_cond)
        strategy.close("Long")
else
    if buySignal and time_cond
        strategy.entry("Long", strategy.long, comment="Long")
    else
        strategy.cancel("Long")
    
    
    if sellSignal and time_cond
        strategy.entry("Short", strategy.short, comment="Short")
    else
        strategy.cancel("Short")

if not time_cond
    strategy.close_all()


もっと