예스스탁
예스스탁 답변
2025-03-04 17:31:15
안녕하세요
예스스탁입니다.
아래 수식을 사용자함수로 만드신후에 사용하시면 됩니다.
사용자함수명 : barssince
반환값형 : 숫자형
input : cond(TrueFalse);
var : bs(-1);
if cond == true Then
{
bs = 0;
}
Else
{
bs = bs+1;
}
barssince = bs;
즐거운 하루되세요
> 고도산 님이 쓴 글입니다.
> 제목 : 수식 변환 부탁드립니다
> 다음 TradingView 수식 중
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])
부분을 예스트레이더로 변환하는 데 어려움이 있습니다. barssince(조건식)을 예스트레이더로 수행하는 함수를 부탁합니다.
================================================================================
study(title="Turtle Trade Channels Indicator", shorttitle="TuTCI@q", 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(low, length)
upper = highest(high, length)
u = plot(upper, "Upper", color=#0094FF)
l = plot(lower, "Lower", color=#ff0000)
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.new(color.red, 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.new(color.white,0))
plotshape(sellSignal and O4<O2[1] ? up : na, title="Short Entry", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 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.new(color.white,0))
plotshape(buyExit and O1<O3[1] ? up : na, title="Long Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.blue,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.new(color.white,0))
plotshape(sellExit and O2<O4[1] ? down : na, title="Short Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.blue,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.new(color.white,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, title="Background")
fill(l, e, color=color2, title="Background")
감사히 잘 받았습니다.
그런데 결과가 조금 다르게 나오는군요.
while !done {
....
....
}
뭐 이렇게 해야 하지 않을까요?
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 수식 변환 부탁드립니다
>
안녕하세요
예스스탁입니다.
아래 수식을 사용자함수로 만드신후에 사용하시면 됩니다.
사용자함수명 : barssince
반환값형 : 숫자형
input : cond(TrueFalse);
var : bs(-1);
if cond == true Then
{
bs = 0;
}
Else
{
bs = bs+1;
}
barssince = bs;
즐거운 하루되세요
> 고도산 님이 쓴 글입니다.
> 제목 : 수식 변환 부탁드립니다
> 다음 TradingView 수식 중
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])
부분을 예스트레이더로 변환하는 데 어려움이 있습니다. barssince(조건식)을 예스트레이더로 수행하는 함수를 부탁합니다.
================================================================================
study(title="Turtle Trade Channels Indicator", shorttitle="TuTCI@q", 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(low, length)
upper = highest(high, length)
u = plot(upper, "Upper", color=#0094FF)
l = plot(lower, "Lower", color=#ff0000)
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.new(color.red, 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.new(color.white,0))
plotshape(sellSignal and O4<O2[1] ? up : na, title="Short Entry", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 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.new(color.white,0))
plotshape(buyExit and O1<O3[1] ? up : na, title="Long Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.blue,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.new(color.white,0))
plotshape(sellExit and O2<O4[1] ? down : na, title="Short Exit", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.blue,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.new(color.white,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, title="Background")
fill(l, e, color=color2, title="Background")