
この戦略は,ブリン帯を主要指標として使用し,閉盤価格が上線を突破すると多仓を開き,下線を突破すると空仓を開きます.ブリン帯は,中線 ((移動平均線),上線 ((中線+標準差) と下線 ((中線-標準差) で構成されています. この戦略は,市場動向を捉え,価格がブリン帯を突破すると買入し,下線を突破すると売却し,同時に中線を平仓条件として使用します.
ブリン帯突破戦略は,ブリン帯を上下軌道に突破して市場トレンドを捕捉し,中軌道を平仓条件とする.この戦略の論理は明確で,容易に実行でき,トレンドを効果的に捕捉することができるが,パラメータ選択と振動市場には一定のリスクがある.将来,他の指標を導入し,パラメータを最適化し,リスク管理などの方法によって戦略のパフォーマンスを向上させることができる.
/*backtest
start: 2023-04-24 00:00:00
end: 2024-04-29 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands Strategy", shorttitle='BB Strategy', overlay=true)
// Bollinger Bands parameters
length = input.int(20, title="Length")
mult = input.float(2.0, title="Multiplier")
// Calculate Bollinger Bands
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper_band = basis + dev
lower_band = basis - dev
// Plot Bollinger Bands
plot(basis, color=color.blue, title="Basis")
plot(upper_band, color=color.red, title="Upper Band")
plot(lower_band, color=color.green, title="Lower Band")
// Strategy
long_condition = ta.crossover(close, upper_band)
short_condition = ta.crossunder(close, lower_band)
if (long_condition)
strategy.entry("Long", strategy.long)
if (short_condition)
strategy.entry("Short", strategy.short)
// Exit conditions
exit_long_condition = ta.crossunder(close, basis)
exit_short_condition = ta.crossover(close, basis)
if (exit_long_condition)
strategy.close("Long")
if (exit_short_condition)
strategy.close("Short")