I am new to trading actions. I am free user of Trading View. There is indicator limit to use for free users. So I want to try combining LuxAlgo – Nadaraya-Watson “Smoothers” and “Envelope” Indicators.
float y2s = na
float y1s = na
float y1_ds = na
line l = na
label lb = na
if barstate.islast and repaint
//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
y2s := sum / sumw
d = y2s - y1s
//Set coordinate line
l := array.get(ln,i)
line.set_xy1(l,n-i+1,y1s)
line.set_xy2(l,n-i,y2s)
line.set_color(l,y2s > y1s ? dnCss : upCss)
line.set_width(l,2)
if d * y1_ds < 0
label.new(n-i+1, src[i], y1_ds < 0 ? '▲' : '▼'
, color = color(na)
, style = y1_ds < 0 ? label.style_label_up : label.style_label_down
, textcolor = y1_ds < 0 ? upCss : dnCss
, textalign = text.align_center)
y1s := y2s
y1_ds := d
//
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
y2 := sum / sumw
sae += math.abs(src[i] - y2)
nwe.push(y2)
sae := sae / math.min(499,n - 1) * mult
for i = 0 to math.min(499,n - 1)
if i%2
line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss)
line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss)
if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae
label.new(n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae
label.new(n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center)
y1 := nwe.get(i)
I tried to combine them but somehow I always missing “Smoothers” line, (I guess y1s, that added “s” to the end because y1 is “Envelope”s line probably.)
enter image description here
Is there anyone willing to combine them and send the code for me or maybe tell what am I missing?
Seyyah-ı Kainat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.