OPEN-SOURCE SCRIPT

Bollinger Band Cross Strategy

//version=5
indicator("Bollinger Band Cross Strategy", overlay=true)

// Input settings for Bollinger Bands
length = input.int(20, title="Bollinger Band Length")
src = input.source(close, title="Source")
mult = input.float(2.0, title="Standard Deviation")

// Bollinger Bands calculations
basis = ta.sma(src, length)
upper = basis + mult * ta.stdev(src, length)
lower = basis - mult * ta.stdev(src, length)
// Plot the Bollinger Bands
plot(basis, color=color.blue, title="Middle Band")
plot(upper, color=color.green, title="Upper Band")
plot(lower, color=color.red, title="Lower Band")

// Buy and Sell conditions
buySignal = ta.crossover(close[1], upper[1]) and ta.crossover(close, upper)
sellSignal = ta.crossunder(close[1], lower[1]) and ta.crossunder(close, lower)

// Exit conditions
exitBuy = ta.crossunder(close, basis)
exitSell = ta.crossover(close, basis)

// Plot Buy and Sell signals
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")

// Plot Exit signals
plotshape(series=exitBuy, location=location.abovebar, color=color.blue, style=shape.circle, title="Exit Buy", text="EXIT")
plotshape(series=exitSell, location=location.belowbar, color=color.orange, style=shape.circle, title="Exit Sell", text="EXIT")

// Alerts
alertcondition(buySignal, title="Buy Alert", message="Two consecutive candles closed above Upper Bollinger Band - BUY")
alertcondition(sellSignal, title="Sell Alert", message="Two consecutive candles closed below Lower Bollinger Band - SELL")
alertcondition(exitBuy, title="Exit Buy Alert", message="Candle closed below Middle Bollinger Band - EXIT BUY")
alertcondition(exitSell, title="Exit Sell Alert", message="Candle closed above Middle Bollinger Band - EXIT SELL")
Bands and Channels

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?

免責事項