예스스탁
예스스탁 답변
2024-09-19 16:40:03
안녕하세요
예스스탁입니다.
input : Periods(10);
input : Multiplier(3.0);
input : changeATR(true);
input : showsignals(true);
input : highlighting(true);
var : src(0),ar(0),up(0),up1(0),dn(0),dn1(0),trend(0),tx(0);
src = (h+l)/2;
ar = ma(TrueRange, Periods);
up = src-(Multiplier*ar);
up1 = iff(IsNan(up[1])==true,up,up[1]);
up = iff(close[1] > up1 , max(up,up1) , up);
dn=src+(Multiplier*ar);
dn1 = IFf(IsNan(dn[1])==true, dn,dn[1]);
dn = iff(close[1] < dn1 , min(dn, dn1) , dn);
trend = 1;
trend = iff(IsNan(trend[1])==true, trend,trend[1]);
trend = iff(trend == -1 and close > dn1 , 1 ,IFf(trend == 1 and close < up1 , -1 , trend));
if trend == 1 Then
plot1(up,"Up Trend",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);
}
즐거운 하루되세요
> 파생돌이 님이 쓴 글입니다.
> 제목 : 부틱드립니다
> 수고하십니다
트레이딩 뷰 수식입니다.
예스로적용가능하도록 부탁 드립니다.
//@version=4
study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")
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!")