'PineScript MultiFrame repainting
i'm new to pinescript and i would like to repaint automatically a Bollinger Bands MTF. The problem is when i set the bands on 5min MTF and i go on 1min chart, it will trace every 1min. Thanks for your help.
//@version=4
study(title="MTF Bollinger Bands", shorttitle="MTF 2 BB", overlay=true)
onoffA = input(true, "BB1")
resA = input(title='BB1 TF', type=input.resolution, defval="60")
bres = input(defval=true, title="Use Current Resolution")
sigmaA = input(2, title='BB1 Sigma', step=1, minval=1, maxval=3)
onoffB = input(true, "BB2")
resB = input(title='BB1 TF', type=input.resolution, defval="240")
sigmaB = input(2, title='BB2 Sigma', step=1, minval=1, maxval=3)
res1 = bres ? timeframe.period : resA
devA = security(syminfo.tickerid, res1, stdev(close, 20))
basisA = security(syminfo.tickerid, res1, sma(close, 20))
devB = security(syminfo.tickerid, resB, stdev(close, 20))
basisB = security(syminfo.tickerid, resB, sma(close, 20))
upper_1 = onoffA ? basisA + devA * sigmaA : na
lower_1 = onoffA ? basisA - devA * sigmaA : na
upper_2 = onoffB ? basisB + devB * sigmaB : na
lower_2 = onoffB ? basisB - devB * sigmaB : na
plot(onoffA ? basisA : na, color=color.red, title='BB1 Basis')
plot(onoffB ? basisB : na, color=color.orange, title='BB2 Basis')
u1 = plot(upper_1, color=color.blue, title='BB1 Upper')
l1 = plot(lower_1, color=color.blue, title='BB1 Lower')
u2 = plot(upper_2, color=color.green, title='BB2 Upper')
l2 = plot(lower_2, color=color.green, title='BB2 Lower')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
