커뮤니티

예스트레이더 수식으로 변환 문의드립니다.

프로필 이미지
로즈버드
2020-02-10 15:16:17
336
글번호 135795
답변완료
//input variables Length=input(title="Look Back Period", type=integer, defval=22) ATRPeriod=input(title="ATR Period", type=integer, defval=22) Mult=input(title="ATR Multiplier", type=integer, defval=3) //calculate stop value short_stop = lowest(Length)+Mult*atr(ATRPeriod) long_stop = highest(Length)-Mult*atr(ATRPeriod) shortvs=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1])) longvs=na(longvs[1]) ? long_stop : iff(close<longvs[1], long_stop, max(long_stop,longvs[1])) longswitch=iff (close>=shortvs[1] and close[1]<shortvs[1] , 1 , 0) shortswitch=iff (close<=longvs[1] and close[1]>longvs[1] , 1 , 0) direction= iff(na(direction[1]), 0, iff (direction[1]<=0 and longswitch, 1, iff (direction[1]>=0 and shortswitch, -1, direction[1]))) pc=direction>0?longvs:shortvs plot(pc, color=direction>0?aqua:fuchsia, style=circles, linewidth=2) plot(pc, color=direction>0?aqua:fuchsia, style=line, linewidth=2) 감사합니다.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2020-02-10 16:58:24

안녕하세요 예스스탁입니다. input : Length(22),ATRPeriod(22),Mult(3); var : short_stop(0),long_stop(0),shortvs(0),longvs(0),longswitch(0),shortswitch(0),direction(0),pc(0); short_stop = lowest(l,Length)+Mult*atr(ATRPeriod); long_stop = highest(h,Length)-Mult*atr(ATRPeriod); shortvs = iff(IsNaN(shortvs[1]) == true, short_stop, iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1]))); longvs = iff(IsNaN(longvs[1]) == true,long_stop, iff(close<longvs[1], long_stop, max(long_stop,longvs[1]))); longswitch = iff (close>=shortvs[1] and close[1]<shortvs[1] , 1 , 0); shortswitch = iff (close<=longvs[1] and close[1]>longvs[1] , 1 , 0); direction= iff(IsNaN(direction[1]) == true, 0, iff (direction[1]<=0 and longswitch, 1, iff (direction[1]>=0 and shortswitch, -1, direction[1]))); pc=iff(direction>0,longvs,shortvs); plot1(pc,"pc1",iff(direction>0,MAGENTA,CYAN)); plot2(pc,"pc2",iff(direction>0,MAGENTA,CYAN)); 즐거운 하루되세요 > 로즈버드 님이 쓴 글입니다. > 제목 : 예스트레이더 수식으로 변환 문의드립니다. > //input variables Length=input(title="Look Back Period", type=integer, defval=22) ATRPeriod=input(title="ATR Period", type=integer, defval=22) Mult=input(title="ATR Multiplier", type=integer, defval=3) //calculate stop value short_stop = lowest(Length)+Mult*atr(ATRPeriod) long_stop = highest(Length)-Mult*atr(ATRPeriod) shortvs=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1])) longvs=na(longvs[1]) ? long_stop : iff(close<longvs[1], long_stop, max(long_stop,longvs[1])) longswitch=iff (close>=shortvs[1] and close[1]<shortvs[1] , 1 , 0) shortswitch=iff (close<=longvs[1] and close[1]>longvs[1] , 1 , 0) direction= iff(na(direction[1]), 0, iff (direction[1]<=0 and longswitch, 1, iff (direction[1]>=0 and shortswitch, -1, direction[1]))) pc=direction>0?longvs:shortvs plot(pc, color=direction>0?aqua:fuchsia, style=circles, linewidth=2) plot(pc, color=direction>0?aqua:fuchsia, style=line, linewidth=2) 감사합니다.