Bollinger Bands Width with Squeeze Alert

danarm · study · 24 行 · 点赞 949 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=4
study(title="Bollinger Bands Width with Squeeze Alert", shorttitle="BBW with Squeeze", precision=2)
 
comp_len=input(125, "Back comparison period for squeeze detection (bars)")
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50)
 
bbwidth() =>
    basis = sma(src, length)
    dev = mult * stdev(src, length)
    upper = basis + dev
    lower = basis - dev
    (upper-lower)/basis
 
bbw=bbwidth()
 
squeeze= bbw==lowest(bbw, comp_len)
 
bgcolor(squeeze ? color.fuchsia : na, transp=75)
 
plot(bbw, "BBW", color=#138484), hline(0)
 
alertcondition(squeeze, "Bollinger squeeze ", "Bollinger squeeze ")

← 返回列表