OPEN-SOURCE SCRIPT

Candle Closes Outside Bollinger Bands

//version=5
indicator("Candle Closes Outside Bollinger Bands", overlay=true)

// Bollinger Bands parameters
length = input.int(20, title="BB Length")
src = close
mult = input.float(2.0, title="BB Multiplier")

// Bollinger Bands Calculation
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upperBB = basis + dev
lowerBB = basis - dev

// Condition for closing outside of the Bollinger Bands
closeAboveUpperBB = close > upperBB
closeBelowLowerBB = close < lowerBB

// Plotting signals
plotshape(closeAboveUpperBB, title="Close Above Upper BB", location=location.abovebar, color=color.green, style=shape.labelup, text="Close > Upper BB")
plotshape(closeBelowLowerBB, title="Close Below Lower BB", location=location.belowbar, color=color.red, style=shape.labeldown, text="Close < Lower BB")

// Optionally, plot the Bollinger Bands for visual reference
plot(upperBB, color=color.blue, title="Upper BB")
plot(lowerBB, color=color.blue, title="Lower BB")
Bands and Channels

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明