OPEN-SOURCE SCRIPT

Bollinger Band Reversal

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

// Bollinger Bands Parameters
length = 20
src = close
mult = 2.0

// Calculate Bollinger Bands
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper_band = basis + dev
lower_band = basis - dev

// Conditions
close_outside_upper = close > upper_band
close_outside_lower = close < lower_band

// Detect reversal
candle_reversal = (close_outside_upper[1] and close < upper_band) or (close_outside_lower[1] and close > lower_band)

// Plot Bollinger Bands
plot(upper_band, color=color.red, linewidth=2, title="Upper Band")
plot(lower_band, color=color.green, linewidth=2, title="Lower Band")
plot(basis, color=color.blue, linewidth=1, title="Basis")

// Mark the condition on the chart
bgcolor(candle_reversal ? color.new(color.green, 90) : na, title="Candle Reversal Background")

// Display alerts
alertcondition(candle_reversal, title="Bollinger Band Reversal Alert", message="Candle closed outside BB, next candle closed inside BB")
Bands and Channels

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明