//@version=5 indicator("Bollinger Bands with Weighted Volatility", overlay=false) //…
Jump to turn (6)
- 1//@version=5 indicator("Bollinger Bands with Weighted Volatility", overlay=false
- 2write pine script ver 4 of the code , avoid using any builtin function in librar
- 39:14:44 PM Error at 2:0 no viable alternative at character '“'
- 4replace each “ with " , and replace each ” with "
- 5//@version=4 study(title="Bollinger Bands with Weighted Volatility", overlay=fal
- 6don't use quote marks “ or ” , only use "
- User
//@version=5 indicator("Bollinger Bands with Weighted Volatility", overlay=false)
// Input Variables length = input.int(title="Length", defval=20, minval=1) deviations = input.float(title="Deviations", defval=2.0, minval=0.1, step=0.1) volatility_length = input.int(title="Volatility Length", defval=20, minval=1)
// Calculate Bollinger Bands source = close basis = ta.sma(source, length) dev = deviations * ta.stdev(source, length) upper = basis + dev lower = basis - dev
// Calculate Volatility Weighted by Volume volatility = ta.stdev(change(source), volatility_length) volatility_weighted = volatility * ta.volume
// Plot Bollinger Bands and Volatility Weighted by Volume plot(basis, color=color.blue, title="Basis") fill(upper, lower, color=color.blue, title="Bollinger Bands") plot(volatility_weighted, color=color.yellow, title="Volatility Weighted by Volume", style=plot.style_columns)
// Set Y-Axis Scale for Volatility Window volatility_scale = ta.scalediff(high, low) * 2 volatility_scale := volatility_scale == 0? 1 : volatility_scale
// Plot Volatility Window plot(volatility_weighted, color=color.yellow, title="Volatility Weighted by Volume", style=plot.style_columns, secondary_y=true, scale=scale.inherit, min=0, max=volatility_scale)