Hello,
I have this code below for Nadaraya Watson Indicator, I would like to make a Screener out of it. I want price to be below 200 SMA and price (high) to touch the Nadaraya top(high). Please see below:
Could you please help me with how to translate it into screener? Thank you.
code for Nadaraya Watson is:
//Nadaraya-Watson Envelope
defparam drawonlastbaronly = true
length = Min(500,BarIndex)
hh = 8 //Bandwidth
mult = .3
src = Close
n = barindex
k = 2
if IsLastBarUpdate then
y2 = 0
sume = 0
for i = 0 to length-1
sum = 0
sumw = 0
for j = 0 to length-1
w = EXP(-pow(i-j,2)/(hh*hh*2))
sum = sum+src[j]*w
sumw = sumw+w
next
y2 = sum/sumw
sume = sume+abs(src[i] – y2)
$a[barindex-i]=y2
//DRAWPOINT(barindex-i, y2, 1)
next
mae = sume/(length*mult)
for i=0 to length-1
DRAWPOINT(barindex-i, $a[barindex-i]-mae, 2) coloured(0,255,0,100)
DRAWPOINT(barindex-i, $a[barindex-i]+mae, 2) coloured(255,0,0,100)
//if close[barindex-i] > ($a[barindex-i]+mae) then // and src[1]<y2[1]+mae then
//drawarrowdown(barindex-i,high) coloured(“red”)
//endif
//if close[barindex-i] < ($a[barindex-i]-mae) then //and src[1]>y2[1]-mae then
//drawarrowup(barindex-i,low) coloured(“green”)
//endif
next
/*drawpoint(barindex,y2,1)
drawpoint(barindex,y2+mae,1)
drawpoint(barindex,y2-mae,1)*/
Y2High=$a[barindex]+mae
Y2Low=$a[barindex]-mae
endif
return y2,y2+mae,y2-mae