커뮤니티
지표식 수정 부탁드립니다.
2013-10-11 20:19:36
214
글번호 68382
inputs: price((h+l)/2), alpha(.07), cutoff(8);
vars: smooth(0),cycle(0),q1(0),i1(0),deltaphase(0),mediandelta(0),dc(0),instperiod(0),period(0),
num(0),denom(0),a1(0),b1(0),c1(0),coef1(0),coef2(0),coef3(0),coef4(0),filt3(0);
smooth = (price + 2*price[1] + 2*price[2] + price[3])/6;
cycle = (1-.5*alpha)*(1-.5*alpha)*(smooth-2*smooth[1]+smooth[2]) + 2*(1-alpha)*cycle[1]
- (1-alpha)*(1-alpha)*cycle[2];
if currentbar < 7 then cycle = (price-2*price[1]+price[2])/4;
q1 = (.0962*cycle + .5769*cycle[2] - .5769*cycle[4] - .0962*cycle[6])*(.5+.08*instperiod[1]);
i1 = cycle[3];
if q1<>0 and q1[1]<>0 then deltaphase = (i1/q1-i1[1]/q1[1]) / (1+i1*i1[1]/(q1*q1[1]));
if deltaphase < 0.1 then deltaphase=0.1;
if deltaphase > 1.1 then deltaphase=1.1;
mediandelta = median(deltaphase,5);
if mediandelta = 0 then dc=15; else dc=6.28318/mediandelta + .5;
instperiod = .33*dc + .67*instperiod[1];
period = .15*instperiod + .85*period[1];
value1 = price - price[intportion(period-1)];
a1 = expvalue(-3.14159 / cutoff);
b1 = 2*a1*cosine(1.738*180 / cutoff);
c1 = a1*a1;
coef2 = b1 + c1;
coef3 = -(c1 + b1*c1);
coef4 = c1*c1;
coef1 = 1 - coef2 - coef3 - coef4;
filt3 = coef1*value1 + coef2*filt3[1] + coef3+filt3[2] + coef4*filt3[3];
if currentbar < 4 then filt3= value1;
plot1(filt3);
위와 같은 지표가 있습니다. 이지 랭귀지로 작성된 지표인데 예스랭귀지와는 다르게
순차적 인식 뿐 아니라 동시적(?) 인식도 거기에서는 되는가 봅니다.
q1을 정의할때 instperiod 가 나오는데 instperiod의 정의는 한참 밑에 나오며
instperiod 정의 시 dc 가 필요한데 또 dc를 정의하려면 medianphase 및 mediandelta 가
필요하고 medianphase 를 정의하려면 q1 이 필요한 순환 논리로 식이 구성되어 있습니다.
어떻게 재구성해야 예스랭귀지로 구현할 수 있는지 알려주시면 감사하겠습니다.
median 함수는 저번에 알려주신대로 사용자 함수로 등록해 놓았습니다.
감사합니다.
답변 1
예스스탁 예스스탁 답변
2013-10-14 14:46:08
안녕하세요
예스스탁입니다.
이지랭귀지도 예스랭귀지와 식을 읽어 가는 방향은 위에서 아래로 동일합니다.
q1계산시에는 현재봉의 instperiod가 아닌 한봉전의 instperiod를 이용하며
나머지도 모두 계산할때보다 한줄 이상 위에 배치해 있거나 하므로
동시에 읽어들어가거나 하는 부분은 아닙니다.
수식 전체를 if currentbars >= 1 then 조건으로 묶으시면 해결이 됩니다.
수식에서 필요한 봉갯수 이후부터 계산을 하라는 의미가 됩니다.
다만 해당 식의 value1값에 문제가 있습니다.
price - price[intportion(period-1)]
위 계산식에서 intportion(period-1)에 의해 이전에 참조할 봉이 정해지는데
해당 봉번호가 현재봉의 인덱스보다 크면
이전의 봉이 없어 값을 가져올수 없어 N/A가 발생하게 됩니다.
이 N/A가 발생하면 지표는 숫자만 출력하게 되어 있어
지표가 이후에 그려지지 않습니다.
해당 부분은 작성하신 계산의 의해서 나오는 숫자를
이전값으로 사용하는 부분이라
수정을 해드릴수가 없습니다. 위 내용 살펴보시기 바랍니다.
inputs: price((h+l)/2), alpha(.07), cutoff(8);
vars: smooth(0),cycle(0),q1(0),i1(0),deltaphase(0),mediandelta(0),dc(0),instperiod(0),period(0),
num(0),denom(0),a1(0),b1(0),c1(0),coef1(0),coef2(0),coef3(0),coef4(0),filt3(0);
if CurrentBar >= 1 then{
smooth = (price + 2*price[1] + 2*price[2] + price[3])/6;
cycle = (1-.5*alpha)*(1-.5*alpha)*(smooth-2*smooth[1]+smooth[2]) + 2*(1-alpha)*cycle[1]
- (1-alpha)*(1-alpha)*cycle[2];
if currentbar < 7 then cycle = (price-2*price[1]+price[2])/4;
q1 = (.0962*cycle + .5769*cycle[2] - .5769*cycle[4] - .0962*cycle[6])*(.5+.08*instperiod[1]);
i1 = cycle[3];
if q1<>0 and q1[1]<>0 then deltaphase = (i1/q1-i1[1]/q1[1]) / (1+i1*i1[1]/(q1*q1[1]));
if deltaphase < 0.1 then deltaphase=0.1;
if deltaphase > 1.1 then deltaphase=1.1;
mediandelta = median(deltaphase,5);
if mediandelta == 0 then dc=15; else dc=6.28318/mediandelta + .5;
instperiod = .33*dc + .67*instperiod[1];
period = .15*instperiod + .85*period[1];
value1 = price - price[intportion(period-1)];
a1 = expvalue(-3.14159 / cutoff);
b1 = 2*a1*cosine(1.738*180 / cutoff);
c1 = a1*a1;
coef2 = b1 + c1;
coef3 = -(c1 + b1*c1);
coef4 = c1*c1;
coef1 = 1 - coef2 - coef3 - coef4;
filt3 = coef1*value1 + coef2*filt3[1] + coef3+filt3[2] + coef4*filt3[3];
if currentbar < 4 then filt3= value1;
}
plot1(filt3);
즐거운 하루되세요
> 임네닉 님이 쓴 글입니다.
> 제목 : 지표식 수정 부탁드립니다.
> inputs: price((h+l)/2), alpha(.07), cutoff(8);
vars: smooth(0),cycle(0),q1(0),i1(0),deltaphase(0),mediandelta(0),dc(0),instperiod(0),period(0),
num(0),denom(0),a1(0),b1(0),c1(0),coef1(0),coef2(0),coef3(0),coef4(0),filt3(0);
smooth = (price + 2*price[1] + 2*price[2] + price[3])/6;
cycle = (1-.5*alpha)*(1-.5*alpha)*(smooth-2*smooth[1]+smooth[2]) + 2*(1-alpha)*cycle[1]
- (1-alpha)*(1-alpha)*cycle[2];
if currentbar < 7 then cycle = (price-2*price[1]+price[2])/4;
q1 = (.0962*cycle + .5769*cycle[2] - .5769*cycle[4] - .0962*cycle[6])*(.5+.08*instperiod[1]);
i1 = cycle[3];
if q1<>0 and q1[1]<>0 then deltaphase = (i1/q1-i1[1]/q1[1]) / (1+i1*i1[1]/(q1*q1[1]));
if deltaphase < 0.1 then deltaphase=0.1;
if deltaphase > 1.1 then deltaphase=1.1;
mediandelta = median(deltaphase,5);
if mediandelta = 0 then dc=15; else dc=6.28318/mediandelta + .5;
instperiod = .33*dc + .67*instperiod[1];
period = .15*instperiod + .85*period[1];
value1 = price - price[intportion(period-1)];
a1 = expvalue(-3.14159 / cutoff);
b1 = 2*a1*cosine(1.738*180 / cutoff);
c1 = a1*a1;
coef2 = b1 + c1;
coef3 = -(c1 + b1*c1);
coef4 = c1*c1;
coef1 = 1 - coef2 - coef3 - coef4;
filt3 = coef1*value1 + coef2*filt3[1] + coef3+filt3[2] + coef4*filt3[3];
if currentbar < 4 then filt3= value1;
plot1(filt3);
위와 같은 지표가 있습니다. 이지 랭귀지로 작성된 지표인데 예스랭귀지와는 다르게
순차적 인식 뿐 아니라 동시적(?) 인식도 거기에서는 되는가 봅니다.
q1을 정의할때 instperiod 가 나오는데 instperiod의 정의는 한참 밑에 나오며
instperiod 정의 시 dc 가 필요한데 또 dc를 정의하려면 medianphase 및 mediandelta 가
필요하고 medianphase 를 정의하려면 q1 이 필요한 순환 논리로 식이 구성되어 있습니다.
어떻게 재구성해야 예스랭귀지로 구현할 수 있는지 알려주시면 감사하겠습니다.
median 함수는 저번에 알려주신대로 사용자 함수로 등록해 놓았습니다.
감사합니다.
다음글
이전글