repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations')
//-----------------------------------------------------------------------------} //Append lines //-----------------------------------------------------------------------------{ n = bar_index
var ln = array.new_line(0)
if barstate.isfirst and repaint for i = 0 to 499 array.push(ln,line.new(na,na,na,na))
//-----------------------------------------------------------------------------} //End point method //-----------------------------------------------------------------------------{ var coefs = array.new_float(0) var den = 0.
if barstate.isfirst and not repaint for i = 0 to 499 w = gauss(i, h) coefs.push(w)
den := coefs.sum()
out = 0. if not repaint for i = 0 to 499 out += src * coefs.get(i) out /= den mae = ta.sma(math.abs(src - out), 499) * mult
upper = out + mae lower = out - mae
//-----------------------------------------------------------------------------} //Compute and display NWE //-----------------------------------------------------------------------------{ float y2 = na float y1 = na
nwe = array.new<float>(0) if barstate.islast and repaint sae = 0. //Compute and set NWE point for i = 0 to math.min(499,n - 1) sum = 0. sumw = 0. //Compute weighted mean for j = 0 to math.min(499,n - 1) w = gauss(i - j, h) sum += src[j] * w sumw += w
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.