커뮤니티

수식 전환 부탁드립니다

프로필 이미지
seayun1
2023-03-28 22:16:09
1486
글번호 167633
답변완료
trading view 수식, 예스트레이더 변환 부탁드립니다 study(title="Twin Range Filter", overlay=true) source = input(defval=close, title="Source") // Smooth Average Range per1 = input(defval=27, minval=1, title="Fast period") mult1 = input(defval=1.6, minval=0.1, title="Fast range") per2 = input(defval=55, minval=1, title="Slow period") mult2 = input(defval=2, minval=0.1, title="Slow range") smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ema(abs(x - x[1]), t) smoothrng = ema(avrng, wper) * m smoothrng smrng1 = smoothrng(source, per1, mult1) smrng2 = smoothrng(source, per2, mult2) smrng = (smrng1 + smrng2) / 2 // Range Filter rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r rngfilt filt = rngfilt(source, smrng) upward = 0.0 upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward = 0.0 downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) hband = filt + smrng lband = filt - smrng longCond = bool(na) shortCond = bool(na) longCond := source > filt and source > source[1] and upward > 0 or source > filt and source < source[1] and upward > 0 shortCond := source < filt and source < source[1] and downward > 0 or source < filt and source > source[1] and downward > 0 CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] long = longCond and CondIni[1] == -1 short = shortCond and CondIni[1] == 1 // Plotting plotshape(long, title="Long", text="Long", style=shape.labelup, textcolor=color.black, size=size.tiny, location=location.belowbar, color=color.lime, transp=0) plotshape(short, title="Short", text="Short", style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=color.red, transp=0) // Alerts alertcondition(long, title="Long", message="Long") alertcondition(short, title="Short", message="Short")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-03-29 10:07:03

안녕하세요 예스스탁입니다. 지표식과 시스템식 2개 올려드립니다. 1 지표 input : per1(27),mult1(1.6),per2(55),mult2(2); var : source(0); var : wper1(0),avrng1(0),smrng1(0),wper2(0),avrng2(0),smrng2(0),smrng(0); var : nzrngfilt(0),filt(0),upward(0),downward(0); var : hband(0),lband(0),longCond(False),shortCond(False),CondIni(0),long(False),short(False); source = C; wper1 = per1 * 2 - 1; avrng1= ema(abs(source - source[1]), per1); smrng1 = ema(avrng1, wper1) * mult1; wper2 = per2 * 2 - 1; avrng2= ema(abs(source - source[1]), per2); smrng2 = ema(avrng2, wper2) * mult2; smrng = (smrng1 + smrng2) / 2; // Range Filter filt = source; nzrngfilt = iff(IsNan(filt[1]) ==False, filt[1],0); filt = iff(source > nzrngfilt , IFf( source - smrng < nzrngfilt , nzrngfilt, source - smrng) , iff(source + smrng > nzrngfilt , nzrngfilt, source + smrng)); upward = 0.0; upward = iff(filt > filt[1] , IFf(IsNaN(upward[1])==False,upward[1],0) + 1 , IFf(filt < filt[1] , 0 , IFf(IsNaN(upward[1])==False,upward[1],0))); downward = 0.0; downward = iff(filt < filt[1] , IFf(IsNaN(downward[1])==False,downward[1],0) + 1 , IFf(filt > filt[1] , 0 , IFf(IsNaN(downward[1])==False,downward[1],0))); hband = filt + smrng; lband = filt - smrng; longCond = source > filt and source > source[1] and upward > 0 or source > filt and source < source[1] and upward > 0; shortCond = source < filt and source < source[1] and downward > 0 or source < filt and source > source[1] and downward > 0; CondIni = 0; CondIni = iff(longCond , 1 , IFf(shortCond , -1 , CondIni[1])); long = longCond and CondIni[1] == -1; short = shortCond and CondIni[1] == 1; Plot1(hband); plot2(lband); plot3(filt); 2 시스템 input : per1(27),mult1(1.6),per2(55),mult2(2); var : source(0); var : wper1(0),avrng1(0),smrng1(0),wper2(0),avrng2(0),smrng2(0),smrng(0); var : nzrngfilt(0),filt(0),upward(0),downward(0); var : hband(0),lband(0),longCond(False),shortCond(False),CondIni(0),long(False),short(False); source = C; wper1 = per1 * 2 - 1; avrng1= ema(abs(source - source[1]), per1); smrng1 = ema(avrng1, wper1) * mult1; wper2 = per2 * 2 - 1; avrng2= ema(abs(source - source[1]), per2); smrng2 = ema(avrng2, wper2) * mult2; smrng = (smrng1 + smrng2) / 2; // Range Filter filt = source; nzrngfilt = iff(IsNan(filt[1]) ==False, filt[1],0); filt = iff(source > nzrngfilt , IFf( source - smrng < nzrngfilt , nzrngfilt, source - smrng) , iff(source + smrng > nzrngfilt , nzrngfilt, source + smrng)); upward = 0.0; upward = iff(filt > filt[1] , IFf(IsNaN(upward[1])==False,upward[1],0) + 1 , IFf(filt < filt[1] , 0 , IFf(IsNaN(upward[1])==False,upward[1],0))); downward = 0.0; downward = iff(filt < filt[1] , IFf(IsNaN(downward[1])==False,downward[1],0) + 1 , IFf(filt > filt[1] , 0 , IFf(IsNaN(downward[1])==False,downward[1],0))); hband = filt + smrng; lband = filt - smrng; longCond = source > filt and source > source[1] and upward > 0 or source > filt and source < source[1] and upward > 0; shortCond = source < filt and source < source[1] and downward > 0 or source < filt and source > source[1] and downward > 0; CondIni = 0; CondIni = iff(longCond , 1 , IFf(shortCond , -1 , CondIni[1])); long = longCond and CondIni[1] == -1; short = shortCond and CondIni[1] == 1; // Plotting if long Then Buy("long"); if short Then Sell("short"); 즐거운 하루되세요 > seayun1 님이 쓴 글입니다. > 제목 : 수식 전환 부탁드립니다 > trading view 수식, 예스트레이더 변환 부탁드립니다 study(title="Twin Range Filter", overlay=true) source = input(defval=close, title="Source") // Smooth Average Range per1 = input(defval=27, minval=1, title="Fast period") mult1 = input(defval=1.6, minval=0.1, title="Fast range") per2 = input(defval=55, minval=1, title="Slow period") mult2 = input(defval=2, minval=0.1, title="Slow range") smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ema(abs(x - x[1]), t) smoothrng = ema(avrng, wper) * m smoothrng smrng1 = smoothrng(source, per1, mult1) smrng2 = smoothrng(source, per2, mult2) smrng = (smrng1 + smrng2) / 2 // Range Filter rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r rngfilt filt = rngfilt(source, smrng) upward = 0.0 upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward = 0.0 downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) hband = filt + smrng lband = filt - smrng longCond = bool(na) shortCond = bool(na) longCond := source > filt and source > source[1] and upward > 0 or source > filt and source < source[1] and upward > 0 shortCond := source < filt and source < source[1] and downward > 0 or source < filt and source > source[1] and downward > 0 CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] long = longCond and CondIni[1] == -1 short = shortCond and CondIni[1] == 1 // Plotting plotshape(long, title="Long", text="Long", style=shape.labelup, textcolor=color.black, size=size.tiny, location=location.belowbar, color=color.lime, transp=0) plotshape(short, title="Short", text="Short", style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=color.red, transp=0) // Alerts alertcondition(long, title="Long", message="Long") alertcondition(short, title="Short", message="Short")