ボリンジャー・バンドストップ・ロスの戦略

作者: リン・ハーンチャオチャン,日付: 2023-11-23 15:49:12
タグ:

img

概要

ボリンジャーバンド戦略は,トレンド追跡とオーバーバイト/オーバーセールシグナルのためにボリンジャーバンドを使用する古典的な戦略である.このバージョンは,元の戦略よりもリスクを制御するためにストップロスのメカニズムを追加する.

この戦略は,ポジションを確立するために上/下ボリンジャーバンドのゴールデン/デッドクロスオーバーを通じてオーバーバイト/オーバーセール条件を判断する.バンド間の領域は現在の市場変動範囲を反映する.バンドは,中間,上,下帯で構成され,中帯はN日間の単純な移動平均線であり,上/下帯は中帯+/-K標準偏差である.

原則

ボリンジャー帯は市場の変動性と振動範囲を反映する.下の帯に触ると,過剰に売れた現状を意味する - ギャップは埋められる可能性が高い.したがって,平均逆転原則に基づいてロングポジションを検討すべきである.同様に,上部帯に触ると,潜在的過剰購入状態と価格逆転が起こり得るので,ダウン動きから利益を得るためにショートポジションを確立することができます.

この戦略は,トレンド追跡エントリのためにボリンジャーバンドからの過剰購入/過剰売却信号を組み合わせます.リスク制御のためにストップ・ロスのメカニズムが組み込まれています.

価格が下帯を超えると,市場は過剰販売領域から合理的な範囲に脱出する.ロングポジションは開けることができる.価格が上帯を超えると,市場は過剰購入される.その後ショートを開くことができる.

オーダーが完了した後,リスクを管理するために固定パーセントストップ・ロスのレベルが設定されます.損失がストップ・ロスのパーセントを超えると,さらなる損失を制限するために現在のポジションは停止されます.

利点

  1. 低買い高売りセットアップでは,バンドクロスオーバーを判断して,ボリンジャー帯で過買い/過売りレベルを特定する.

  2. 波リンジャー・バンドの変動特性を利用して 傾向を把握する

  3. ストップ・ロスのメカニズムは,取引ごとに最大損失を有効に制限します.

  4. トレンドトラッキングとストップロスの組み合わせは 安定した利益につながります

リスク と 最適化

  1. パラメータ設定は信号品質に影響を与える. 中間帯域長Nと標準偏差倍数Kは,異なる市場のために合理的に設定する必要があります.

  2. ストップ損失の大きさが大きすぎたり小さすぎたりすると,リターン安定性が損なわれる.過大な割合は,取引ごとに大きな損失を伴うリスクが高く,過小な割合は,早期ストップ損失を誘発するリスクが高くなります.合理的な割合は,異なる製品に基づいて設定する必要があります.

  3. 他の指標の追加フィルターは信号の精度を向上させる可能性があります.

  4. 異なる保持期間設定をテストできる.例えば,より高い周波数取引と資本利用効率の向上のために,時間帯または短い期間帯を組み合わせることなど.

結論

この戦略は,オーバーバイト/オーバーセールシグナルのためにボリンジャーバンドを活用し,リスク管理のためにストップロスを組み込む.これは一般的なトレンド追跡戦略である.パラメータを最適化し,より正確な信号とストップロスのレベルを統合することで,安定した利益を達成することができる.


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

//@version=5
strategy(title="Bollinger Bands Strategy", overlay=false, shorttitle="BBS", pyramiding=0, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.03, initial_capital=1000)
source = input(close, "Source")
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50, step=0.001)
stopLossFactor = input.float(1, "Stop Loss Percent", maxval = 100, minval = 0, step=0.1)

basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev

var float lastTradePrice = na
var float stopLossLow = na
var float stopLossHigh = na
var bool currentIsLong = na

var bool nextExpectedIsLong = true

var bool existedLong = false
var bool existedShort = false

buyEntry = ta.crossover(source, lower)
sellEntry = ta.crossunder(source, upper)

if (buyEntry and nextExpectedIsLong == true)
	strategy.entry("BBandLE", strategy.long, comment="BBandLE")
	nextExpectedIsLong := false
	if(nz(strategy.position_size[1], 0) < 0) // new position detected
	    lastTradePrice := close
	    stopLossLow := lastTradePrice * (1 - (stopLossFactor / 100))
	    stopLossHigh := lastTradePrice * (1 + (stopLossFactor / 100))
else
    strategy.cancel("BBandLE")

if (sellEntry and nextExpectedIsLong == false)
	strategy.entry("BBandSE", strategy.short, comment="BBandSE")
	nextExpectedIsLong := true
	if(nz(strategy.position_size[1], 0) > 0) // new position detected
        lastTradePrice := close
        stopLossLow := lastTradePrice * (1 - (stopLossFactor / 100))
        stopLossHigh := lastTradePrice * (1 + (stopLossFactor / 100))
else
    strategy.cancel("BBandSE")

strategy.close("BBandLE", close < stopLossLow)
strategy.close("BBandSE", close > stopLossHigh)

// if(nz(strategy.position_size[1], 0) < 0 and close > stopLossHigh)
//     strategy.entry("BBandLE", strategy.long, comment="BBandLE")
// 	lastTradePrice := close
// 	stopLossLow := lastTradePrice * (1 - (stopLossFactor / 100))
// 	stopLossHigh := lastTradePrice * (1 + (stopLossFactor / 100))
// if(nz(strategy.position_size[1], 0) > 0 and close < stopLossLow)
//     strategy.exit("BBandSE", strategy.short, comment="BBandSE")
//     lastTradePrice := close
//     stopLossLow := lastTradePrice * (1 - (stopLossFactor / 100))
//     stopLossHigh := lastTradePrice * (1 + (stopLossFactor / 100))

plot(source, "close", color.blue)
plot(lower, "lower", color.red)
plot(upper, "upper", color.red)
plot(stopLossLow, "StopLossLow", color.black)
plot(stopLossHigh, "StopLossHigh", color.black)
plot(lastTradePrice, "lastTradePrice", color.green)
plotchar(strategy.position_size > 0, char="-", size=size.tiny, location=location.bottom, color=color.green)
plotchar(strategy.position_size < 0, char="-", size=size.tiny, location=location.bottom, color=color.red)




もっと