フォローライン戦略

作者: リン・ハーンチャオチャン, 日付: 2023-12-01 18:31:39
タグ:

img

概要

フォローライン戦略は,ボリンジャーバンドと平均真差 (ATR) をベースとしたトレンド追跡戦略である.価格がボリンジャーバンド上部帯を超えると上部帯を超えると下部帯を超えると上部方向に移動することによってトレンド判断ラインを動的に調整してトレンドを追跡する.

戦略の論理

この戦略は,まずボリンジャーバンドの上位および下位帯,および平均真の範囲を計算します. その後,価格がボリンジャーバンド上位または下位帯を超えて破るかどうかを判断します.

価格が上位帯を超えると,ATRフィルタが有効であれば,トレンドラインはATRを抜いた最低価格に設定されます.ATRフィルタが無効であれば,トレンドラインは直接最低価格に設定されます.

価格が下帯を下回ると,ATRフィルタが有効であれば,トレンドラインは最高価格プラスATRに設定されます.ATRフィルタが無効であれば,トレンドラインは直接最高価格に設定されます.

したがって,トレンド判断線は,トレンドを追跡するためにボリンジャーバンドの価格ブレイクに基づいて動的に調整できます.

現在のトレンドラインが前のものより高ければ 上向きの傾向を示します.現在のトレンドラインが前のものより低い場合 下向きの傾向を示します.

トレーディング・シグナルは,トレンド判断に基づいて,ロングまたはショートになるように生成できます.

利点を分析する

  • 動的に調整するトレンドラインは,価格傾向を柔軟に把握することができます.
  • ボリンジャー・バンドと組み合わせると,バンド・ブレイクでトレンド逆転を判断できます.
  • ATRフィルターを導入することで,いくつかの偽のブレイクアウト信号を避けることができます

リスク分析

  • BB パラメータが不適切であれば,頻繁に誤ったブレイクが発生する可能性があります.
  • 過剰なATRパラメータは,トレンド逆転の機会を逃す可能性があります
  • 極端な動きから損失を防ぐために停止損失を検討する必要があります.

いくつかのリスクは,ストップ損失を導入するパラメータチューニングによって軽減できます.また,ブレイクアウト有効性を向上させるために,シグナルフィルタリングのための他の指標と組み合わせることができます.

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

  • 最適な設定を見つけるためにBBとATRパラメータを最適化
  • 偽ブレイクをフィルターするために他の指標を追加します
  • BBとATR期間を特定取引手段に基づいて選択する

結論

フォローライン戦略は,不安定な市場における価格動向を把握することを目的としている.これは効果的なトレンド追跡戦略である.適切なパラメータ調節と最適化は,立派な利益をもたらすことができる.しかし,リスクはストップ損失と誤ったブレイクを防ぐことで管理する必要がある.この戦略を他の指標または戦略と組み合わせて収益性をさらに向上させることが推奨される.


/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © Dreadblitz
//@version=4
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //

strategy(title = " Strategy Follow Line Indicator ",
         shorttitle = "S-FLI",
         overlay = true,
         precision = 8,
         calc_on_order_fills = true,
         calc_on_every_tick = true,
         backtest_fill_limits_assumption = 0,
         default_qty_type = strategy.fixed,
         default_qty_value = 2,
         initial_capital = 10000,
         pyramiding=1,
         currency = currency.USD,
         linktoseries = true)

//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //

backTestSectionFrom = input(title = "═══════════════ From ═══════════════", defval = true, type = input.bool)

FromMonth         = input(defval = 1, title = "Month", minval = 1)
FromDay           = input(defval = 1, title = "Day", minval = 1)
FromYear          = input(defval = 2014, title = "Year", minval = 2000)

backTestSectionTo = input(title = "════════════════ To ════════════════", defval = true, type = input.bool)
ToMonth           = input(defval = 31, title = "Month", minval = 1)
ToDay             = input(defval = 12, title = "Day", minval = 1)
ToYear            = input(defval = 9999, title = "Year", minval = 2000)

Config            = input(title = "══════════════ Config ══════════════", defval = true, type = input.bool)
BBperiod          = input(defval = 21,     title = "BB Period",    type = input.integer, minval = 1)
BBdeviations      = input(defval = 1.00,     title = "BB Deviations",    type = input.float, minval = 0.1, step=0.05)
UseATRfilter      = input(defval = true, title = "ATR Filter",  type = input.bool)
ATRperiod         = input(defval = 5,     title = "ATR Period",    type = input.integer, minval = 1)
hl                = input(defval = false, title = "Hide Labels",  type = input.bool)


backTestPeriod() => true

//
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ //

BBUpper=sma (close,BBperiod)+stdev(close, BBperiod)*BBdeviations
BBLower=sma (close,BBperiod)-stdev(close, BBperiod)*BBdeviations
//
TrendLine = 0.0
iTrend = 0.0
buy = 0.0
sell = 0.0
//
BBSignal = close>BBUpper? 1 : close<BBLower? -1 : 0
// 
if BBSignal == 1 and UseATRfilter == 1
    TrendLine:=low-atr(ATRperiod)
    if TrendLine<TrendLine[1] 
        TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 1
    TrendLine:=high+atr(ATRperiod)
    if TrendLine>TrendLine[1]
        TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 1
    TrendLine:=TrendLine[1]
//
if BBSignal == 1 and UseATRfilter == 0
    TrendLine:=low
    if TrendLine<TrendLine[1] 
        TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 0
    TrendLine:=high
    if TrendLine>TrendLine[1]
        TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 0
    TrendLine:=TrendLine[1]
//
iTrend:=iTrend[1]
if TrendLine>TrendLine[1] 
    iTrend:=1
if TrendLine<TrendLine[1] 
    iTrend:=-1
//
buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na
sell:=iTrend[1]==1 and iTrend==-1? 1 : na
//
plot(TrendLine, color=iTrend > 0?color.blue:color.red ,style=plot.style_line,linewidth=2,transp=0,title="Trend Line") 
plotshape(buy == 1 and hl == false? TrendLine-atr(8) :na, text='💣', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)
plotshape(sell == 1 and hl == false ?TrendLine+atr(8):na, text='🔨', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)

// Strategy Entry
if (backTestPeriod())
    strategy.entry("long", true, 1, when = buy == 1)
    strategy.entry("short", false, 1, when = sell == 1) 

もっと