커뮤니티

지표식 변환 문의드립니다.

프로필 이미지
임네닉
2013-10-11 02:40:03
377
글번호 68329
답변완료
트레이드 스테이션용 이지 랭귀지로 작성된 지표를 변환하고자 합니다. Median (Function) Disclaimer The Median function returns the middle value after sorting numbers over a specified range of bars. Syntax Median(Price, Length) Returns (Double) A numeric value containing the median value of a specified number of sorted values. Parameters Name Type Description Price Numeric Specifies which bar value (price, function, or formula) to use. Length Numeric Sets the number of bars to consider. Remarks The input Price tells the function what values to look at, while the Length input tells the function how many bars to include in the calculations. The function will sort Length number of Price elements in ascending order and return the middle element. If Length is an even number, it will choose the two values that fall at the middle of the sort and average them. See Table 1. If Length is an odd number the function will return the middle value. See Table 2. Table 1 Bar Number Price Rank (1 = smallest) Median Close[0] 3646.6 &#1048687; Close[1] 3625.0 &#1048686; Close[2] 3667.1 &#1048688; Close[3] 3669.6 &#1048689; Length = 4 3656.8 Table 2 Bar Number Price Rank (1 = smallest) Median Close[0] 3646.6 &#1048687; Close[1] 3625.0 &#1048686; Close[2] 3667.1 &#1048688; Close[3] 3669.6 &#1048689; Close[4] 3670.0 &#1048690; Length = 5 3667.1 Price is a numeric series type input. The input Length must be a whole number as it represents the number of bars, and it cannot change on a bar-to-bar basis. Example Value1 = Median(Close,10); 위와 같이 median 함수가 정의됩니다.(이지 랭귀지에서) 아래의 식에 median 함수가 있어 어떻게 해야 하는지 여쭙니다. inputs: price(c), 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); plot2(0); 위의 식은 제가 예스트레이더에 맞도록 약간 수정해 놓았습니다. 해결 안되는 부분은 MEDIAN 함수이고 (MEDIANPRICE 함수과 다릅니다) 이것이 해결되었을 때 다른 오류가 없는지 확인 부탁드립니다. 참고로 위의 식은 John. F. Ehlers 의 cybernetic analysis for stocks and futures 에 나와 있는 지표입니다. (smoothed adaptive momentum) 감사합니다.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2013-10-11 16:36:27

안녕하세요 예스스탁입니다. 이지랭귀지의 사용자함수를 예스랭귀지 문법으로 변경한 식입니다, 사용자 함수로 작성해서 사용하시면 됩니다. #(함수명 : Median, 반환값형 : 숫자형) Inputs: Price(Numeric), Length(Numeric); Variables: HalfLength(0); HalfLength = Length * 0.5; IF FracPortion(HalfLength) == 0 Then Median = (NthHighest(HalfLength, Price, Length) + NthHighest(HalfLength + 1, Price, Length)) * 0.5; Else Median = NthHighest(IntPortion(HalfLength + 1), Price, Length); 즐거운 하루되세요 > 임네닉 님이 쓴 글입니다. > 제목 : 지표식 변환 문의드립니다. > 트레이드 스테이션용 이지 랭귀지로 작성된 지표를 변환하고자 합니다. Median (Function) Disclaimer The Median function returns the middle value after sorting numbers over a specified range of bars. Syntax Median(Price, Length) Returns (Double) A numeric value containing the median value of a specified number of sorted values. Parameters Name Type Description Price Numeric Specifies which bar value (price, function, or formula) to use. Length Numeric Sets the number of bars to consider. Remarks The input Price tells the function what values to look at, while the Length input tells the function how many bars to include in the calculations. The function will sort Length number of Price elements in ascending order and return the middle element. If Length is an even number, it will choose the two values that fall at the middle of the sort and average them. See Table 1. If Length is an odd number the function will return the middle value. See Table 2. Table 1 Bar Number Price Rank (1 = smallest) Median Close[0] 3646.6 &#1048687; Close[1] 3625.0 &#1048686; Close[2] 3667.1 &#1048688; Close[3] 3669.6 &#1048689; Length = 4 3656.8 Table 2 Bar Number Price Rank (1 = smallest) Median Close[0] 3646.6 &#1048687; Close[1] 3625.0 &#1048686; Close[2] 3667.1 &#1048688; Close[3] 3669.6 &#1048689; Close[4] 3670.0 &#1048690; Length = 5 3667.1 Price is a numeric series type input. The input Length must be a whole number as it represents the number of bars, and it cannot change on a bar-to-bar basis. Example Value1 = Median(Close,10); 위와 같이 median 함수가 정의됩니다.(이지 랭귀지에서) 아래의 식에 median 함수가 있어 어떻게 해야 하는지 여쭙니다. inputs: price(c), 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); plot2(0); 위의 식은 제가 예스트레이더에 맞도록 약간 수정해 놓았습니다. 해결 안되는 부분은 MEDIAN 함수이고 (MEDIANPRICE 함수과 다릅니다) 이것이 해결되었을 때 다른 오류가 없는지 확인 부탁드립니다. 참고로 위의 식은 John. F. Ehlers 의 cybernetic analysis for stocks and futures 에 나와 있는 지표입니다. (smoothed adaptive momentum) 감사합니다.