トレンドトラッキング ストップ損失 利益 戦略

作者: リン・ハーンチャオチャン開催日:2024年1月24日 14:17:28
タグ:

img

概要

これはトレンド追跡戦略で,トレンドを決定するためにボリンジャーバンドとATRを使用してストップ・ロストとテイク・プロフィートを設定します.まず市場トレンドを判断し,トレンドラインを描き,ポジションを閉じるときにストップ・ロストとテイク・プロフィートを設定します.

戦略の論理

  1. ボリンジャー帯の上下線を計算する.
  2. 閉店価格が上線線線上にあるか下線線下にあるかを判断します.そうであれば,順番にトレンド市場,上昇または下線として判断します.
  3. トレンドラインを計算します. トレンドラインは,最低価格マイナスATR値 (牛市場) または最高価格プラスATR値 (熊市場) に基づきます.
  4. トレンドラインは前行と同じで
  5. トレンドラインを比較して トレンド方向を決める.上昇傾向は上昇傾向,下落傾向は下落傾向です.
  6. トレンドラインの方向が変わるときに 買い/売るシグナルを生成します
  7. 固定ストップ損失距離は入場価格の100倍で,浮動ストップ損失距離は入場価格の1.1倍 (bull) または0.9倍 (bear) です.

利点分析

  1. 市場動向を判断し 偽のブレイクトレードを回避できます
  2. トランスラインを設定して 罠にはまらないように
  3. 合理的なストップ・ロストと利益設定をすることで,利益を確保しながらリスクをコントロールできます.

リスク分析

  1. パラメータの設定が正しくない場合 取引機会を逃す可能性があります
  2. 波リンジャー・バンドは 範囲限定市場では 誤った判断をする可能性が高いのです
  3. ストップ損失が近づいてしまうと 簡単にストップを止められます

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

  1. Bollinger Bands のパラメータを異なる製品に最適化する
  2. トレンドラインの計算方法を最適化し,例えば他の指標を導入する.
  3. ストップ・ロスの設定をテストし最適化し 利益を取ります

結論

この戦略は,トレンドを決定するためにボリンジャーバンドを使用し,トレンドラインに基づいてストップ・ロスを設定し,利益を引き出す戦略である.主な利点は,明確なトレンド判断,合理的なストップ・ロスト,リスクを効果的に制御するための利益を引き出す設定である.主なリスクは,ボリンジャーバンドの間違ったトレンド判断とストップ・ロスの接近から生じる.将来の最適化方向性にはパラメータ最適化,トレンドライン計算最適化,ストップ・ロスの利益を引き出す最適化が含まれます.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zhuenrong

// © Dreadblitz
//@version=4
strategy(shorttitle="FLI", title="Follow Line Indicator", overlay=true)
// 
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)
//
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)
//
alertcondition(sell == 1 ,title="Sell",message="Sell")
alertcondition(buy == 1 ,title="Buy",message="Buy")
alertcondition(buy == 1 or sell == 1 ,title="Buy/Sell",message="Buy/Sell")
if (buy==1)
    strategy.entry("Buy", strategy.long)
if (sell==1)
    strategy.entry("Sell", strategy.short)
// === Stop LOSS ===

if strategy.position_size>0
    strategy.exit("Stop Loss/Profit Long","Buy", stop=strategy.position_avg_price*100, limit=strategy.position_avg_price*1.1)
if strategy.position_size<0
    strategy.exit("Stop Loss/Profit Short","Sell", stop=strategy.position_avg_price*100, limit=strategy.position_avg_price*0.9)

もっと