예스스탁
예스스탁 답변
2022-12-12 14:22:10
안녕하세요
예스스탁입니다.
if crossup(emav, xATRTrailingStop) Then ab == true ;
if crossup(xATRTrailingStop, emav) Then be == true ;
위 내용에 오류가 있습니다.
변수에 값저장은 = 입니다. == 는 같다라는 표현입니다.
또한 변수에 값이 한번 저장되면 다음변경시 까지 값을 유지하는데
올리신 내용은 조건이 만족하면 TRUE 아니면 FALSE가 저장되게 작성하셔야 합니다.
ab와 be는 true나 false가 저장되므로
선언시 0이 아닌 false로 선언하셔야 합니다.
아래는 수정한 식입니다.
Input : a(1), length(10),크기(15);
var : truehighv(0),TrueLowv(0),TrueRangev(0),xatr(0),nLoss(0),src(0) ;
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : xATRTrailingStop(0),poss(0), emav(0), ab(False), be(False),tx(0) ;
var : dir(0) ;
if index == 0 then
{
xOpen = open;
xClose = (O+H+L+C)/4;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
////////
If xClose[1] > xHigh then
TrueHighv = xClose[1];
else
TrueHighv = xHigh;
If xClose[1] < xLow then
TrueLowv = xClose[1];
else
TrueLowv = xLow;
TrueRangev = TrueHighv - TrueLowv;
xatr = ma(TrueRangev,length);
nLoss = a * xatr ;
##########
src = xClose ;
xATRTrailingStop = 0.0 ;
xATRTrailingStop = iff(src > xATRTrailingStop[1] and src[1] > xATRTrailingStop[1],
max(xATRTrailingStop[1], src - nLoss),
iff(src < xATRTrailingStop[1] and src[1] < xATRTrailingStop[1],
min(xATRTrailingStop[1],src + nLoss),
iff(src > xATRTrailingStop[1], src - nLoss, src + nLoss)));
poss = 0 ;
poss = iff(src[1] < xATRTrailingStop[1] and src > xATRTrailingStop[1], 1,
iff(src[1] > xATRTrailingStop[1] and src < xATRTrailingStop[1], -1, poss[1])) ;
emav = ema(src,1);
if crossup(emav, xATRTrailingStop) Then
ab = true ;
Else
ab = False;
if crossup(xATRTrailingStop, emav) Then
be = true ;
Else
be = False;
////////////
dir = iff(src > xATRTrailingStop and ab == true , 1 ,iff( src < xATRTrailingStop and be == true , -1 , dir));
Plot1( dir);
if dir == 1 and dir[1] == -1
Then
{
tx = Text_New(sDate,sTime,low,"▲");
Text_SetStyle(tx,2,0);
Text_SetSize(tx, 크기);
Text_SetColor(tx,black);
}
if dir == -1 and dir[1] == 1
Then
{
tx = Text_New(sDate,sTime,high,"▼");
Text_SetStyle(tx,2,1);
Text_SetSize(tx, 크기);
Text_SetColor(tx,black);
}
즐거운 하루되세요
> 당일선물 님이 쓴 글입니다.
> 제목 : 수식 검증 수정부탁드립니다.
>
트레이딩뷰 지표를 예스지표로 변환하려는데,
어디서 오류가 있는것인지 출력이 되지 않습니다.
점검 수정 부탁드립니다.
////////////////트레이딩뷰 원 지표식 //////////
study(title="UT Bot Alerts", overlay = true)
// Inputs
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
c = input(10, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")
xATR = atr(c)
nLoss = a * xATR
src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close
xATRTrailingStop = 0.0
xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss)))
pos = 0
pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
ema = ema(src,1)
above = crossover(ema, xATRTrailingStop)
below = crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
alertcondition(buy, "UT Long", "UT Long")
alertcondition(sell, "UT Short", "UT Short")
////////// 제가 변환해본 식 ////////
Input : a(1), length(10),크기(15);
var : truehighv(0),TrueLowv(0),TrueRangev(0),xatr(0),nLoss(0),src(0) ;
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : xATRTrailingStop(0),poss(0), emav(0), ab(0), be(0),tx(0) ;
var : dir(0) ;
if index == 0 then
{
xOpen = open;
xClose = (O+H+L+C)/4;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
////////
If xClose[1] > xHigh then
TrueHighv = xClose[1];
else
TrueHighv = xHigh;
If xClose[1] < xLow then
TrueLowv = xClose[1];
else
TrueLowv = xLow;
TrueRangev = TrueHighv - TrueLowv;
xatr = ma(TrueRangev,length);
nLoss = a * xatr ;
##########
src = xClose ;
xATRTrailingStop = 0.0 ;
xATRTrailingStop = iff(src > xATRTrailingStop[1] and src[1] > xATRTrailingStop[1],
max(xATRTrailingStop[1], src - nLoss),
iff(src < xATRTrailingStop[1] and src[1] < xATRTrailingStop[1],
min(xATRTrailingStop[1],src + nLoss),
iff(src > xATRTrailingStop[1], src - nLoss, src + nLoss)));
poss = 0 ;
poss = iff(src[1] < xATRTrailingStop[1] and src > xATRTrailingStop[1], 1,
iff(src[1] > xATRTrailingStop[1] and src < xATRTrailingStop[1], -1, poss[1])) ;
emav = ema(src,1);
if crossup(emav, xATRTrailingStop) Then ab == true ;
if crossup(xATRTrailingStop, emav) Then be == true ;
////////////
dir = iff(src > xATRTrailingStop and ab == true , 1 ,iff( src < xATRTrailingStop and be == true , -1 , dir));
if dir == 1 and dir[1] == -1
Then
{
tx = Text_New(sDate,sTime,low,"▲");
Text_SetStyle(tx,2,0);
Text_SetSize(tx, 크기);
Text_SetColor(tx,black);
}
if dir == -1 and dir[1] == 1
Then
{
tx = Text_New(sDate,sTime,high,"▼");
Text_SetStyle(tx,2,1);
Text_SetSize(tx, 크기);
Text_SetColor(tx,black);
}
//////////////