ボリンガー・ブレイク・アウト・戦略 ピラミディング

作者: リン・ハーンチャオチャン,日付: 2023-11-23 14:01:57
タグ:

img

概要

この戦略は,ボリンジャーバンドのブレイクアウトに基づいてロングまたはショートポジションに入ります.価格が下帯を下回るとロングになり,価格が上帯を下回るとショートになります.ポジションに入るとピラミッドを継続し,リアルタイムでストップロスを更新します.

戦略の論理

この戦略は,ボリンジャーバンドの3行 - 中間,上,下を使用する. 中間線はn日移動平均線である. 上線は中間線 + k * n日標準偏差線である. 下線は中間線 - k * n日標準偏差線である. 通常 n は 20 で,k は 2 である.

価格が上線の上を突破すると,下向きの傾向を示し,ショートになります.価格が下向きの傾向を突破すると,上向きの傾向を示し,ロングになります.

ポジションを取った後,戦略はピラミッドを保持し,同じ方向により多くのポジションを追加することを意味します.ピラミッド入りルールは,最初のエントリー後に価格が再び中間線に触れたときです.

すべてのポジションのストップロスは,現在の平均保有価格とバンド価格の差に基づいてリアルタイムで更新されます.

利点分析

この戦略の利点は以下の通りである.

  1. ボリンジャー・バンドを使って 突破とトレンドの変化を正確に識別します
  2. 金十字と死十字のポジションを 体系的に入力してください
  3. ピラミッド作りで 利益が増える
  4. リアルタイムストップ損失更新で ノックアウトを避けます

リスク分析

この戦略にはいくつかのリスクもあります:

  1. ボリンジャーバンドは市場の変動に敏感で,ウイプソーが発生する可能性があります.
  2. ピラミッド操作は 暴露を増やし 損失を拡大します
  3. ストップ・ロスは保証されていませんが ストップ・アウトされる確率はまだあります

リスクに対処するための方法:

  1. Bollinger Bands パラメータを異なるサイクルに最適化する.
  2. ピラミッドスケールと周波数を調整する
  3. 中間線をストップ損失線として追加します.

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

戦略は以下の側面から最適化できます.

  1. ボリンジャー・バンドのパラメータを最適化し,より多くの市場体制を調整する.
  2. リスクと報酬のバランスをとるピラミッドの論理を 改善する
  3. 中間線のようなストップ損失線を追加します.
  4. 利潤を積極的に確保するための利潤採取メカニズムを 開発する
  5. 他の指標を組み合わせてエントリをフィルターする.
  6. 取引ごとに損失を制御するためにリスク管理を強化する.

結論

結論として,これは典型的なトレンドフォロー戦略である.トレンドが出現すると勢いを動かし,それに応じて利益を得ます.一方,それには固有のリスクもあります.より多くの市場条件に適応し,ウィップソーリスクに対処するためにさらなる最適化が必要です.


/*backtest
start: 2022-11-16 00:00:00
end: 2023-11-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5

strategy(title='Bollinger Band strategy with split, limit, stop', shorttitle='bb strategy', overlay=true,commission_type = strategy.commission.percent, commission_value = 0.01, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, pyramiding = 4)



//Summary: Going Long or Short when Entering after Breaking the Bollinger Bands\
//At this time, the stop-loss, profit-taking price, and pyramiding standard\
// are determined from the difference between the position average price and the band price.

//After entering the position, if the price crosses the mid-band line, the stop loss is adjusted to the mid-band line.



//each trade, entry position size = 10% of total cash
//max pyramiding is 4
//commission = 0.01%





in_period = true


bb_length = input.int(20)
bb_mult = input.int(2)

[middle, upper, lower] = ta.bb(close,bb_length, bb_mult)
plot(middle, color=color.aqua)
plot(upper, color=color.orange)
plot(lower, color=color.orange)
long_cond = ta.crossover(close,lower)
short_cond = ta.crossunder(close,upper)

var saved_ph = 0.0
if strategy.opentrades>0 and strategy.opentrades[1]==0 and strategy.position_size > 0
    saved_ph := upper[1]
var saved_pl = 0.0
if strategy.opentrades>0 and strategy.opentrades[1]==0 and strategy.position_size < 0
    saved_pl := lower[1]

avg = strategy.position_avg_price

long_diff = saved_ph-avg
short_diff = saved_pl-avg

long_stoploss = avg - 1*long_diff
short_stoploss = avg - 1*short_diff

long_avgdown = avg - 0.5*long_diff
short_avgup = avg - 0.5*short_diff

long_profit_price = avg + 0.5*long_diff
short_profit_price = avg + 0.5*short_diff

var label _label = na
if in_period
    if long_cond and strategy.opentrades==0
        strategy.entry("Long",strategy.long)
    if long_cond and strategy.opentrades >0 and (close[1]<long_avgdown or close[2]<long_avgdown)
        strategy.entry("Long",strategy.long)

    if short_cond and strategy.opentrades==0
        strategy.entry("Short", strategy.short)
    if short_cond and strategy.opentrades>0 and (close[1]>short_avgup or close[2]>short_avgup)
        strategy.entry("Short",strategy.short)

plot(avg, style=plot.style_linebr)


plot(strategy.position_size > 0? long_profit_price: na,color=color.green, style=plot.style_linebr)
plot(strategy.position_size > 0? long_avgdown: na,color=color.yellow, style=plot.style_linebr)
plot(strategy.position_size > 0? long_stoploss: na,color=color.red, style=plot.style_linebr)

plot(strategy.position_size < 0? short_profit_price: na,color=color.green, style=plot.style_linebr)
plot(strategy.position_size < 0? short_avgup: na,color=color.yellow, style=plot.style_linebr)
plot(strategy.position_size < 0? short_stoploss: na,color=color.red, style=plot.style_linebr)

if strategy.position_size > 0
    if ta.crossover(close, middle)
        strategy.exit("Long Exit", "Long", limit=long_profit_price, stop=middle)
    else
        strategy.exit("Long Exit", "Long", limit=long_profit_price, stop=long_stoploss)
if strategy.position_size < 0
    if ta.crossunder(close, middle)
        strategy.exit("Short Exit", "Short", limit=short_profit_price, stop=middle)
    else
        strategy.exit("Short Exit", "Short", limit=short_profit_price, stop=short_stoploss)

もっと