예스스탁
예스스탁 답변
2023-01-27 13:15:28
안녕하세요
예스스탁입니다.
input : length(21),hh(8),mult(2),k(2);
var : src(0),n(0),tx(0),sume(0),i(0),j(0),y2(0),sum(0),sumw(0),w(0),mae(0);
src = Close;
n = barindex;
//if IsLastBar업데이트[영문으로는 쓰기금지라 한글로 씀] and barindex>length then
//y = 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;
}
y2 = sum/sumw;
sume = sume+abs(src[i] - y2);
//array.push(y,y2)
}
mae = sume/length*mult;
/*drawpoint(barindex,y2,1)
drawpoint(barindex,y2+mae,1)
drawpoint(barindex,y2-mae,1)*/
if CrossDown(src,y2+mae) then // and src[1]<y2[1]+mae then
{
tx = Text_New(sdate,stime,H,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,Red);
}
if CrossUp(src,y2-mae) then //and src[1]>y2[1]-mae then
{
Text_New(sdate,stime,L,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Green);
}
Plot1(y2);
Plot2(y2+mae);
Plot3(y2-mae);
즐거운 하루되세요
> 오이도인 님이 쓴 글입니다.
> 제목 : 수식 변환 문의
> 수고 하십니다.
아래 지표식 변환 부탁드립니다.
수고하세요...
###########
//Nadaraya-Watson Envelope
length = 21 //Window Size
hh = 8 //Bandwidth
mult = 2
src = CustomClose
n = barindex
k = 2
//if IsLastBar업데이트[영문으로는 쓰기금지라 한글로 씀] and barindex>length then
//y = 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)
//array.push(y,y2)
next
mae = sume/length*mult
/*drawpoint(barindex,y2,1)
drawpoint(barindex,y2+mae,1)
drawpoint(barindex,y2-mae,1)*/
if src crosses under y2+mae then // and src[1]<y2[1]+mae then
drawarrowdown(barindex,high) coloured("red")
endif
if src crosses over y2-mae then //and src[1]>y2[1]-mae then
drawarrowup(barindex,low) coloured("green")
endif
//endif
return y2,y2+mae,y2-mae