커뮤니티

수식변환요청

프로필 이미지
부호장자
2024-06-10 19:18:38
864
글번호 180485
답변완료
수고 많으십니다. 아래의 트레이딩뷰 지표를 예스로 변환부탁드립니다. study(title="Turtle Trade Channels Indicator", shorttitle="TuTCI", overlay=true, resolution="") length = input(20,"Entry Length", minval=1) len2=input(10, "Exit Length", minval=1) showsignals = input(title="Show Entry/Exit Signals ?", type=input.bool, defval=true) highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true) lower = lowest(length) upper = highest(length) u = plot(upper, "Upper", color=#0094FF) l = plot(lower, "Lower", color=#0094FF) up=highest(high,length) down=lowest(low,length) sup=highest(high,len2) sdown=lowest(low,len2) K1=barssince(high>=up[1])<=barssince(low<=down[1]) ? down : up K2=iff(barssince(high>=up[1])<=barssince(low<=down[1]),sdown,sup) K3=iff(close>K1,down,na) K4=iff(close<K1,up,na) plot(K1, title="Trend Line", color=color.red, linewidth=2) e=plot(K2, title="Exit Line", color=color.blue, linewidth=1, style=6) buySignal=high==upper[1] or crossover(high,upper[1]) sellSignal = low==lower[1] or crossover(lower[1],low) buyExit=low==sdown[1] or crossover(sdown[1],low) sellExit = high==sup[1] or crossover(high,sup[1]) O1= barssince(buySignal) O2= barssince(sellSignal) O3= barssince(buyExit) O4= barssince(sellExit) E1= barssince(buySignal[1]) E2= barssince(sellSignal[1]) E3= barssince(buyExit[1]) E4= barssince(sellExit[1]) plotshape(buySignal and O3<O1[1] ? down : na, title="Long Entry", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) plotshape(buySignal and showsignals and O3<O1[1] ? down : na, title="Long", text="Long Entry", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) plotshape(sellSignal and O4<O2[1] ? up : na, title="Short Entry", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) plotshape(sellSignal and showsignals and O4<O2[1] ? up : na, title="Short", text="Short Entry", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) plotshape(buyExit and O1<O3[1] ? up : na, title="Long Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.blue, transp=0) plotshape(buyExit and showsignals and O1<O3[1] ? up : na, title="Long Exit", text="Exit Long", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.blue, textcolor=color.white, transp=0) plotshape(sellExit and O2<O4[1] ? down : na, title="Short Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.blue, transp=0) plotshape(sellExit and showsignals and O2<O4[1] ? down : na, title="Short", text="Exit Short", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.blue, textcolor=color.white, transp=0) color1= highlighting and min(O1,O2,O3)==O1 ? color.green : na color2= highlighting and min(O1,O2,O4)==O2 ? color.red : na fill(u, e, color=color1, transp=88, title="Background") fill(l, e, color=color2, transp=88, title="Background")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-06-11 09:52:05

안녕하세요 예스스탁입니다. input : length(20); input : len2(10); input : showsignals(true); input : highlighting(true); var : upper(0),lower(0); lower = lowest(L,length); upper = highest(H,length); plot1(upper, "Upper"); plot2(lower, "Lower"); var : up(0),down(0),sup(0),sdown(0); var : k1(0),k2(0),k3(0),k4(0),i1(-1),i2(-1); up=highest(high,length); down=lowest(low,length); sup=highest(high,len2); sdown=lowest(low,len2); if high >= up[1] Then i1 = 0; Else { if i1 >= 0 Then i1 = i1+1; } if Low <= down[1] Then i2 = 0; Else { if i2 >= 0 Then i2 = i2+1; } K1=iff(i1 <=i2, down , up); K2=iff(i1 <= i2,sdown,sup); K3=iff(close>K1,down,nan); K4=iff(close<K1,up,nan); plot3(K1,"Trend Line",red); plot4(K2,"Exit Line",blue); var : buySignal(False),sellSignal(False),buyExit(False),sellExit(False); var : O1(-1),O2(-1),O3(-1),O4(-1); var : E1(-1),E2(-1),E3(-1),E4(-1); var : tx1(0),tx2(0),tx3(0),tx4(0); var : tx5(0),tx6(0),tx7(0),tx8(0); buySignal=high==upper[1] or CrossUp(high,upper[1]); sellSignal = low==lower[1] or CrossUp(lower[1],low); buyExit=low==sdown[1] or CrossUp(sdown[1],low); sellExit = high==sup[1] or CrossUp(high,sup[1]); if BuySignal == true Then var1 = Index; if sellSignal == true Then var2 = Index; if buyExit == true Then var3 = Index; if sellExit == true Then var4 = Index; O1= IFf(var1 > 0,Index-var1,-1); O2= IFf(var2 > 0,Index-var2,-1); O3= IFf(var3 > 0,Index-var3,-1); O4= IFf(var4 > 0,Index-var4,-1); if BuySignal[1] == true Then var5 = Index; if sellSignal[1] == true Then var6 = Index; if buyExit[1] == true Then var7 = Index; if sellExit[1] == true Then var8 = Index; E1= IFf(var5 > 0,Index-var5,-1); E2= IFf(var6 > 0,Index-var6,-1); E3= IFf(var7 > 0,Index-var7,-1); E4= IFf(var8 > 0,Index-var8,-1); if buySignal and O3<O1[1] Then { tx1 = Text_New(sDate,sTime,down,"●"); Text_SetColor(tx1,Green); } if buySignal and showsignals and O3<O1[1] Then { tx2 = Text_New(sDate,sTime,down,"▲"); Text_SetColor(tx2,Green); } if sellSignal and O4<O2[1] Then { tx3 = Text_New(sDate,sTime,up,"●"); Text_SetColor(tx3,Red); } if sellSignal and showsignals and O4<O2[1] Then { tx4 = Text_New(sDate,sTime,down,"▼"); Text_SetColor(tx4,Red); } if buyExit and O1<O3[1] Then { tx5 = Text_New(sDate,sTime,up,"●"); Text_SetColor(tx5,blue); } if buyExit and showsignals and O1<O3[1] Then { tx6 = Text_New(sDate,sTime,down,"▼"); Text_SetColor(tx6,blue); } if sellExit and O2<O4[1] Then { tx7 = Text_New(sDate,sTime,down,"●"); Text_SetColor(tx7,blue); } if sellExit and showsignals and O2<O4[1] Then { tx8 = Text_New(sDate,sTime,down,"▲"); Text_SetColor(tx8,blue); } 즐거운 하루되세요 > 부호장자 님이 쓴 글입니다. > 제목 : 수식변환요청 > 수고 많으십니다. 아래의 트레이딩뷰 지표를 예스로 변환부탁드립니다. study(title="Turtle Trade Channels Indicator", shorttitle="TuTCI", overlay=true, resolution="") length = input(20,"Entry Length", minval=1) len2=input(10, "Exit Length", minval=1) showsignals = input(title="Show Entry/Exit Signals ?", type=input.bool, defval=true) highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true) lower = lowest(length) upper = highest(length) u = plot(upper, "Upper", color=#0094FF) l = plot(lower, "Lower", color=#0094FF) up=highest(high,length) down=lowest(low,length) sup=highest(high,len2) sdown=lowest(low,len2) K1=barssince(high>=up[1])<=barssince(low<=down[1]) ? down : up K2=iff(barssince(high>=up[1])<=barssince(low<=down[1]),sdown,sup) K3=iff(close>K1,down,na) K4=iff(close<K1,up,na) plot(K1, title="Trend Line", color=color.red, linewidth=2) e=plot(K2, title="Exit Line", color=color.blue, linewidth=1, style=6) buySignal=high==upper[1] or crossover(high,upper[1]) sellSignal = low==lower[1] or crossover(lower[1],low) buyExit=low==sdown[1] or crossover(sdown[1],low) sellExit = high==sup[1] or crossover(high,sup[1]) O1= barssince(buySignal) O2= barssince(sellSignal) O3= barssince(buyExit) O4= barssince(sellExit) E1= barssince(buySignal[1]) E2= barssince(sellSignal[1]) E3= barssince(buyExit[1]) E4= barssince(sellExit[1]) plotshape(buySignal and O3<O1[1] ? down : na, title="Long Entry", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) plotshape(buySignal and showsignals and O3<O1[1] ? down : na, title="Long", text="Long Entry", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) plotshape(sellSignal and O4<O2[1] ? up : na, title="Short Entry", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) plotshape(sellSignal and showsignals and O4<O2[1] ? up : na, title="Short", text="Short Entry", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) plotshape(buyExit and O1<O3[1] ? up : na, title="Long Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.blue, transp=0) plotshape(buyExit and showsignals and O1<O3[1] ? up : na, title="Long Exit", text="Exit Long", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.blue, textcolor=color.white, transp=0) plotshape(sellExit and O2<O4[1] ? down : na, title="Short Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.blue, transp=0) plotshape(sellExit and showsignals and O2<O4[1] ? down : na, title="Short", text="Exit Short", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.blue, textcolor=color.white, transp=0) color1= highlighting and min(O1,O2,O3)==O1 ? color.green : na color2= highlighting and min(O1,O2,O4)==O2 ? color.red : na fill(u, e, color=color1, transp=88, title="Background") fill(l, e, color=color2, transp=88, title="Background")