
この戦略は,ブリン帯と移動平均の2つの技術指標を組み合わせて,ブリン帯と価格の相対的な位置と高速移動平均の交差信号によって市場の傾向を判断し,選択した買い物を実現します. 価格がブリン帯を突破すると下軌道に立つとき,ポジションを空けて,ポジションを空けて,ポジションを空けて,ポジションを空けて,ポジションを空けて,ポジションを空けて,ポジションを空けてください.
ブリン帯交差移動平均策略は,ブリン帯判断超買超売を介して,均線交差判断トレンドを利用して,市場トレンドを効果的に把握し,安定した収益を達成できる,クラシックなトレンド追跡策略である.しかし,実際の適用では,回撤を制御し,パラメータを最適化し,他の方法と組み合わせて,変化する市場環境に適応するために継続的に改善する必要があります.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(shorttitle="BB Strategy", title="Bollinger Bands Strategy", overlay=true)
// Input parameters
length = input.int(20, minval=1)
maType = input.string("SMA", "Basis MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
offset = input.int(0, "Offset", minval=-500, maxval=500)
// Moving average function
ma(source, length, _type) =>
switch _type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// Calculate Bollinger Bands
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
// Plot Bollinger Bands
plot(basis, "Basis", color=color.blue, offset=offset)
p1 = plot(upper, "Upper", color=color.red, offset=offset)
p2 = plot(lower, "Lower", color=color.green, offset=offset)
fill(p1, p2, title="Background", color=color.rgb(33, 150, 243, 95))
// Strategy entry and exit conditions
if (ta.crossover(close, lower))
strategy.entry("Buy", strategy.long)
if (ta.crossunder(close, upper))
strategy.entry("Sell", strategy.short)