답변완료
수식 변환 문의
수고 하십니다.
아래 지표식 변환 부탁드립니다.
수고하세요...
###########
//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
2023-01-27
464
글번호 165762
지표
답변완료
추세선 크기 알림
input : Period(140);
Var:j(0),T(0);
Var: date11(0),date12(0),time11(0),time12(0),TL1(0),TL(0),tl9(0),
date21(0),date22(0),time21(0),time22(0),txx(0), vTL(0), vTL9(0),txxx(0),
date31(0),date32(0),time31(0),time32(0),tx(0),tx1(0),tl4(0),tx4(0);
Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0);
Array:r[7](0),fr[7](0),TL2[7](0),TL3[7](0),TX2[7](0),TX3[7](0);
Plot1(0);
For j = 0 To 19
{
HiBar[j] = HiBar[j] + 1;
LoBar[j] = LoBar[j] + 1;
}
if crossup(c,highest(H,Period)[1]) Then
T = 1;
if CrossDown(c,Lowest(L,Period)[1]) Then
T = -1;
If T == -1 Then
{
If T[1] != -1 Then
{
For j = 18 DownTo 0
{
LoVal[j+1] = LoVal[j];
LoBar[j+1] = LoBar[j];
}
LoVal[0] = L;
LoBar[0] = 0;
date11 = date[HiBar[0]];
time11 = stime[HiBar[0]];
Value11 = HiVal[0];
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
date21 = date[HiBar[0]];
time21 = stime[HiBar[0]];
date22 = date[0];
time22 = stime[0];
for j = 0 to 6
{
fr[j] = LoVal[1] + ((HiVal[0] - LoVal[1]) * r[j]);
}
Text_Delete(txx-4);
Condition1 = False;
if Condition3 == False and Value12 < value11-0.45 Then
{
Tx4=Text_New(date11,time11,H+PriceScale*2,"●");
Condition3 = true;
}
}
Else
{
If LoVal[0] > L Then
{
LoVal[0] = L;
LoBar[0] = 0;
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date22 = date[0];
time22 = stime[0];
Text_Delete(tx);
Condition1 = False;
}
Else
{
if Condition1 == False and Value12 < value11-0.45 and Value12 > value11-0.9 Then
if Condition1 == False and H >= value12+PriceScale*3 Then
{
Condition1 = true;
Text_Delete(txx-4);
txx = Text_New(sdate,sTime,H-PriceScale*5,"●");
Text_SetStyle(txx,2,2);
Text_SetColor(txx,Black);
Text_SetSize(txx,20);
}
}
Text_SetString(tx,NumToStr(value12-value11,2));
Text_SetLocation(tx,sDate,sTime,value12);
if Condition3 == False and Value12 < value11-0.45 Then
{
Tx4 =Text_New(date11,time11,H+PriceScale*2,"●");
Condition3 = true;
Text_SetColor(Tx4,Black);
Text_SetStyle(tx4,2,2);
Text_SetSize(tx4,40);
}
}
}
If T == 1 Then
{
If T[1] != 1 Then
{
Text_Delete(txx-4);
if Condition3 == true Then
Text_Delete(tx4);
if abs(value11-value12) >= 0.5 Then
{
}
For j = 18 DownTo 0
{
HiVal[j+1] = HiVal[j];
HiBar[j+1] = HiBar[j];
}
HiVal[0] = H;
HiBar[0] = 0;
date11 = date[LoBar[0]];
time11 = stime[LoBar[0]];
Value11 = LoVal[0];
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
date31 = date[LoBar[0]];
time31 = stime[LoBar[0]];
date32 = date[0];
time32 = stime[0];
for j = 0 to 5
{
fr[j] = LoVal[0] + ((HiVal[1] - LoVal[0]) * r[j]);
}
}
If HiVal[0] < H Then
{
HiVal[0] = H;
HiBar[0] = 0;
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date32 = date[0];
time32 = stime[0];
}
}
하락 추세선의 크기가 0.5p에 도달하면 동그라미가 생겼다가 양전환되면 삭제하는 수식 부분에서 동그라미가 생성 안됨. 수정 부탁합니다.
2023-01-27
699
글번호 165744
지표