예스스탁
예스스탁 답변
2024-10-22 15:03:07
안녕하세요
예스스탁입니다.
input : Periods(10);
input : Multiplier(3.0);
input : changeATR(1);#1:SMA 0:RMA
var : src(0),alpha(0),source(0),ATR1(0),ATR2(0),ATRV(0);
var : up(0),up1(0),dn(0),dn1(0),trend(0),tx(0);
src = (H+L)/2;
alpha = 1 / Periods;
atr1 = IFf(IsNan(atr1[1]) == true , ma(TrueRange, Periods) , alpha * TrueRange + (1 - alpha) * atr1[1]);
atr2 = ATR(Periods);
atrv = IFf(changeATR == 1 , atr1 , atr2);
up=src-(Multiplier*atrv);
up1 = IFf(IsNan(up[1]) == False,up[1],up);
up = iff(close[1] > up1 , max(up,up1) , up);
dn=src+(Multiplier*atrv);
dn1 = IFf(IsNan(dn[1]) == False,dn[1], dn);
dn = iff(close[1] < dn1 , min(dn, dn1) , dn);
trend = 1;
trend = IFf(IsNan(trend[1]) == False,trend[1], trend);
trend = IFf(trend == -1 and close > dn1 , 1 , iff(trend == 1 and close < up1 , -1 , trend));
if trend == 1 Then
plot1(up,"UpTrend",green);
Else
NoPlot(1);
if trend == -1 then
Plot2(dn,"Down Trend",red);
Else
NoPlot(2);
if trend == 1 and trend[1] == -1 Then
{
tx =Text_New(sDate,sTime,up,"●");
Text_SetStyle(tx,2,2);
Text_SetColor(tx,Green);
}
if trend == -1 and trend[1] == 1 Then
{
tx =Text_New(sDate,sTime,dn,"●");
Text_SetStyle(tx,2,2);
Text_SetColor(tx,Red);
}
즐거운 하루되세요
> 만강 님이 쓴 글입니다.
> 제목 : 문의 드립니다
>
안녕하세요
다음 트레이딩뷰 코드을 예스로 전환부탁드립니다
슈퍼트랜드 고딩입니다
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
감사합니다