예스스탁
예스스탁 답변
2024-03-25 13:09:09
안녕하세요
예스스탁입니다.
input : aa(1);
input : cc(10);
input : hh(0);#1:true, 0:False
var : xATR(0),nLoss(0);
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : src(0),xATRTrailingStop(Nan),x(0),iff_1(0),iff_2(0),pos(0),iff_3(0);
var : xcolor(0),Emav(0),above(False),below(False);
var : buySignal(False),SellSignal(False),tx(0);
xATR = atr(cc);
nLoss = aa * xATR;
if index == 0 then
{
xClose = (O+H+L+C)/4;
xOpen = open;
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) ;
}
src = iff(hh == 1 , xClose , close);
xATRTrailingStop = src[1];
x = iff(IsNaN(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]);
iff_1 = iff(src > var1 , src - nLoss , src + nLoss);
iff_2 = iff(src < var1 and src[1] < var1 ,min(var1 , src + nLoss),iff_1);
xATRTrailingStop = iff(src > var1 and src[1] > var1 ,max(var1, src - nLoss) , iff_2);
iff_3 = iff(src[1] > var1 and src < var1 , -1 , iff(IsNan(pos[1])==true, 0,pos[1]));
pos = iff(src[1] < var1 and src > var1 , 1 , iff_3);
xcolor = iff(pos == -1 , red , IFf(pos == 1 , green ,blue));
emav = ema(src, 1);
above = CrossUp(emav, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emav);
buySignal = src > xATRTrailingStop and above;
sellSignal = src < xATRTrailingStop and below;
if buySignal Then
{
tx = text_new(sDate,sTime,L,"▲");
Text_SetColor(tx,Green);
Text_SetStyle(tx,2,0);
}
if sellSignal Then
{
tx = text_new(sDate,sTime,H,"▼");
Text_SetColor(tx,red);
Text_SetStyle(tx,2,1);
}
즐거운 하루되세요
> 산수유 님이 쓴 글입니다.
> 제목 : 스크립트 수정요청
> //@version=5
indicator(title='UT Bot Alerts')
// 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 = ta.atr(c)
nLoss = a * xATR
src = h ? ta.heikinashi(close) : close
var float xATRTrailingStop = na
if (na(xATRTrailingStop))
xATRTrailingStop := src[1]
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buySignal = src > xATRTrailingStop and above
sellSignal = src < xATRTrailingStop and below
plotshape(buySignal, title='Buy Signal', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(sellSignal, title='Sell Signal', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
alertcondition(buySignal, title='UT Long', message='UT Long')
alertcondition(sellSignal, title='UT Short', message='UT Short')위의 전략을 예스트레이드 스크립트로 전환 가능한가요?