スーパートレンド戦略


作成日: 2023-10-13 17:03:55 最終変更日: 2023-10-13 17:03:55
コピー: 0 クリック数: 718
1
フォロー
1617
フォロワー

概要

スーパートレンド戦略は,平均真波幅の計算に基づくトレンド追跡戦略である.これは,平均真波幅を利用して,ストープラインを設定し,価格がストープラインを突破したかどうかを判断してトレンド方向を判断し,取引信号を生成する.

戦略原則

この戦略は,まず,一定の周期における平均真波幅ATRを計算する.それからATR値をスケーリング係数で掛け,長線ストップラインと短線ストップラインを計算する.具体的計算方法は以下の通りである.

atr = mult * atr(length) 

longStop = hl2 - atr

shortStop = hl2 + atr

longはATRの周期長を計算し,multはATRの縮小係数である.

ストップラインを計算した後,トレンドの方向を判断するために,戦略は価格が上記のKラインのストップラインを突破したかどうかを判断し続けます.

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. 平均真波幅を用いてストップラインを計算することで,市場騒音を効率的に除し,より信頼できるトレンド信号を捕捉することができる.

  2. 戦略パラメータが少なく,理解し操作が容易である.ATR周期と倍数係数は,異なる市場環境に適応して調整することができる.

  3. 突破ストップラインを用いてトレンドの方向の変化を判断し,リスクを効果的にコントロールし,時宜にストップ・ロスを行う.

  4. 多方向または双方向の取引を構成し,異なる取引スタイルに対応できます.

  5. 任意の時間周期で使用でき,複数の取引品種に適用されます.

戦略リスク

  1. 震動の状況ではATR値が引き上げられ,ストップラインが幅を広げられ,偽信号が多く発生する可能性がある.

  2. 最適なパラメータの組み合わせは決定できません.ATR周期と倍数は,市場の状況に応じて最適化する必要があります.

  3. 取引品種の最適な取引周期は特定できないので,取引品種ごとにテストを行う必要がある.

  4. 到着のタイミングが決まっていないため,遅延が続いています.

  5. 傾向が弱かった時に空置状態にある可能性のある空置リスクがある.

  6. ストップダメージが突破されるリスクがある場合,ストップダメージラインを適切に緩めるべきである.

戦略最適化の方向性

  1. 他の指標と組み合わせたフィルタリングを考慮して,揺動的な状況で誤信号を発生させないようにする.例えばMACD,RSIなど.

  2. 最適なパラメータの組み合わせを探すために,機械学習または遺伝的アルゴリズムを使用できます.

  3. 異なる品種に対してパラメータを最適化して,最適なATR周期と倍数係数を決定することができる.

  4. 定量的な指標を組み合わせて入学タイミングを判断できる.例えば,入学量,早期入学を避ける.

  5. ポジションを空いているときにポジションを保持する戦略を考える.

  6. 適切な範囲を緩め,トレンド強度指標と組み合わせてストップポジションを最適化することができる.

要約する

スーパートレンド戦略は,平均実際の波幅を計算して動的ストップラインを計算し,価格の突破を判断し,トレンドの変化を検出する,より信頼性の高い,リスクが制御可能なトレンド追跡戦略の1つです. この戦略は,簡単に使用し,複数の取引品種に適用できますが,異なる市場で優れた効果を得るためにパラメータと戦略規則に最適化する必要があります. 他の技術指標と戦略の組み合わせを使用すると,より良い取引パフォーマンスを得ることができます. 全体的に言えば,スーパートレンド戦略は,科学的な概念に基づいています.

ストラテジーソースコード
/*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()