예스스탁
예스스탁 답변
2025-07-03 15:05:54
안녕하세요
예스스탁입니다.
종목검색이 모든 주기에서 최대 500봉 까지 제공됩니다.
속성에서 500봉 지정하고 검색하시기 바랍니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : Periods(15);
input : Multiplier(3.0);
input : changeATR(true);
var : src(0),A1(0),atr2(0),atr1(0),atr(0);
var : up(0),up1(0),dn(0),dn1(0),trend(0);
var : buySignal(False),sellSignal(False);
var : stGreen(False),stRed(False);
var : stBuySignal(False),stSellSignal(False);
src = (h+L)/2;
A1 = 1 / periods;
atr1 = IFf(IsNan(atr1[1]) == true, ma(TrueRange,periods) , A1 * TrueRange + (1 - A1) * IFf(isnan(atr1[1])==true,0,atr1[1]));
atr2 = ma(TrueRange, Periods);
atr = iff(changeATR == true, atr1 , atr2);
up = src - Multiplier * atr;
up1 = iff(IsNan(up[1]) == true, up, up[1]);
up = iff(close[1] > up1 , max(up, up1) , up);
dn = src + Multiplier * atr;
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));
buySignal = trend == 1 and trend[1] == -1;
sellSignal = trend == -1 and trend[1] == 1;
if trend == 1 Then
stGreen = true;
Else
stGreen = false;
if trend == -1 Then
stRed = true;
Else
stRed = false;
stBuySignal = buySignal;
stSellSignal = sellSignal;
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
input : length(70);
input : mult(1.2);
var : srcA(0),lag(0),zlema(0),A3(0),atr3(0),volatility(0);
var : trendA(0),zeroLagGreen(False),zeroLagRed(False);
srcA = close;
lag = floor((length - 1) / 2);
zlema = ema(srcA + (srcA - srcA[lag]), length);
A3 = 1 / length;
atr3 = IFf(IsNan(atr3[1]) == true, ma(TrueRange,length) , A3 * TrueRange + (1 - A3) * IFf(isnan(atr3[1])==true,0,atr3[1]));
volatility = highest(atr3, length*3) * mult;
if CrossUp(close, zlema+volatility) Then
trendA = 1;
if CrossDown(close, zlema-volatility) Then
trendA = -1;
if trendA == 1 Then
zeroLagGreen = true;
Else
zeroLagGreen = False;
if trendA == -1 Then
zeroLagRed = true;
Else
zeroLagRed = False;
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
var : ma1(0),ma2(0),smaCrossOver(False),smaCrossUnder(False),sma20Green(False),sma20BreakOut(False);
ma1 = ma(C,20);
ma2 = ma(c,50);
smaCrossOver = CrossUp(ma1,ma2);
smaCrossUnder = CrossDown(ma1,ma2);
sma20Green = ma1 >= ma1[1];
sma20BreakOut = (open < ma1) and (close > ma1);
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : aa(2),cc(20),hk(False);
var : A4(0),xATR(0),nloss(0);
var : xClose(0),xOpen(0),xHigh(0),xLow(0),srcC(0);
A4 = 1 / cc;
xATR = IFf(IsNan(xATR[1]) == true, ma(TrueRange,cc) , A4 * TrueRange + (1 - A4) * IFf(isnan(xATR[1])==true,0,xATR[1]));
nLoss = aa * xATR;
#Heiken Ashi 시고저종
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) ;
}
srcC = Iff(hk == true,xclose ,close);
var : xATRTrailingStop(0),nz1(0),iff_1(0),iff_2(0),nz2(0),ps(0),iff_3(0),xcolor(0);
xATRTrailingStop = 0.0;
nz1 = iff(IsNaN(xATRTrailingStop[1]), 0,xATRTrailingStop[1]);
iff_1 = iff(srcC > nz1, srcC - nLoss , srcC + nLoss);
iff_2 = iff(srcC < nz1 and srcC[1] < nz1 , min(nz1, srcC + nLoss) , iff_1);
xATRTrailingStop = iff(srcC > nz1 and srcC[1] > nz1 , max(nz1, srcC - nLoss) , iff_2);
nz2 = iff(IsNaN(ps[1]), 0,ps[1]);
ps = 0 ;
iff_3 = iff(srcC[1] > nz1 and srcC < nz1 , -1 , nz2);
ps = iff(srcC[1] < nz1 and srcC > nz1 , 1 , iff_3);
xcolor = iff(ps == -1 , red , iff(ps == 1 , green , blue));
var : emav(0),above(False),below(False);
var : Buycond(False),Sellcond(False);
var : barbuy(False),barsell(False);
var : UTBuyCond(False),UTSellCond(False);
emav = ema(srcC, 1);
above = CrossUp(emav, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emav);
Buycond = srcC > xATRTrailingStop and above;
sellcond = srcC < xATRTrailingStop and below;
barbuy = srcC > xATRTrailingStop;
barsell = srcC < xATRTrailingStop;
// RETURNS
if buycond == true Then
UTBuyCond = true;
Else
UTBuyCond = False;
if sellcond == true Then
UTSellCond = true;
Else
UTSellCond = false;
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var : totalLongCond(False),totalLongExitCond(False);
totalLongCond = stGreen and zeroLagGreen and (UTBuyCond or stBuySignal);
totalLongExitCond = stRed or zeroLagRed;
if totalLongCond == true Then
Find(1);
즐거운 하루되세요
> 리버피닉스 님이 쓴 글입니다.
> 제목 : 아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
> 안녕하세요, 제가 트레이딩뷰 자동매매에서 사용하던 전략인데, 예스트레이더 종목검색으로 변환이 가능한지 문의 드립니다.
단순하게, ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때, 발생하는 슈퍼트렌드 혹은 UT Bot alerts등의 신호가 발생했을시,진입을 하는 그런 전략입니다. 예스트레이더의 종목검색으로 변환 가능한지 문의 드립니다. 감사합니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
Periods = 15 // input(title='ATR Period', defval=10)
src = hl2 // input(hl2, title='Source')
Multiplier = 3.0 // input.float(title='ATR Multiplier', step=0.1, defval=3.0)
changeATR = true // input(title='Change ATR Calculation Method ?', defval=true)
showsignals = true // input.bool(title='Show Buy/Sell Signals ?', defval=true, group = "SuperTrend")
highlighting = false // input.bool(title='Highlighter On/Off ?', defval=false, group = "SuperTrend")
// CALCULATIONS
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.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
// PLOTS
// upPlot = plot(trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
buySignal = trend == 1 and trend[1] == -1
// dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
sellSignal = trend == -1 and trend[1] == 1
// plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))
// plotshape(buySignal and showsignals ? up : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
// plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))
// plotshape(sellSignal and showsignals ? dn : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 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, transp=90)
// fill(mPlot, dnPlot, title='DownTrend Highligter', color=shortFillColor, transp=90)
// RETURNS
stGreen = (trend == 1) ? true : false
stRed = (trend == -1) ? true : false
stBuySignal = buySignal
stSellSignal = sellSignal
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
length = 70 // input.int(70, "Length", tooltip = "The Look-Back window for the Zero-Lag EMA calculations", group = "Main Calculations")
mult = 1.2 // input.float(1.2, "Band Multiplier", tooltip = "This value controls the thickness of the bands, a larger value makes the indicato less noisy", group = "Main Calculations")
t1 = "5" // input.timeframe("5", "Time frame 1", group = "Extra Timeframes")
t2 = "15" // input.timeframe("15", "Time frame 2", group = "Extra Timeframes")
t3 = "60" // input.timeframe("60", "Time frame 3", group = "Extra Timeframes")
t4 = "240" // input.timeframe("240", "Time frame 4", group = "Extra Timeframes")
t5 = "1D" // input.timeframe("1D", "Time frame 5", group = "Extra Timeframes")
green = #00ffbb // input.color(#00ffbb, "Bullish Color", group = "Appearance")
red = #ff1100 // input.color(#ff1100, "Bearish Color", group = "Appearance")
// CALCULATIONS
srcA = close
lag = math.floor((length - 1) / 2)
zlema = ta.ema(srcA + (srcA - srcA[lag]), length)
volatility = ta.highest(ta.atr(length), length*3) * mult
var trendA = 0
if ta.crossover(close, zlema+volatility)
trendA := 1
if ta.crossunder(close, zlema-volatility)
trendA := -1
// PLOTS
zlemaColor = trendA == 1 ? color.new(green, 70) : color.new(red, 70)
// m = plot(zlema, title="Zero Lag Basis", linewidth=2, color=zlemaColor)
// upper = plot(trendA == -1 ? zlema+volatility : na, style = plot.style_linebr, color = color.new(red, 90), title = "Upper Deviation Band")
// lower = plot(trendA == 1 ? zlema-volatility : na, style = plot.style_linebr, color = color.new(green, 90), title = "Lower Deviation Band")
// fill(m, upper, (open + close) / 2, zlema+volatility, color.new(red, 90), color.new(red, 70))
// fill(m, lower, (open + close) / 2, zlema-volatility, color.new(green, 90), color.new(green, 70))
// plotshape(ta.crossunder(trendA, 0) ? zlema+volatility : na, "Bearish Trend", shape.labeldown, location.absolute, red, text = "▼", textcolor = chart.fg_color, size = size.small)
// plotshape(ta.crossover(trendA, 0) ? zlema-volatility : na, "Bullish Trend", shape.labelup, location.absolute, green, text = "▲", textcolor = chart.fg_color, size = size.small)
// plotchar(ta.crossover(close, zlema) and trendA == 1 and trendA[1] == 1 ? zlema-volatility*1.5 : na, "Bullish Entry", "▲", location.absolute, green, size = size.tiny)
// plotchar(ta.crossunder(close, zlema) and trendA == -1 and trendA[1] == -1 ? zlema+volatility*1.5 : na, "Bearish Entry", "▼", location.absolute, red, size = size.tiny)
s1 = request.security(syminfo.tickerid, t1, trendA)
s2 = request.security(syminfo.tickerid, t2, trendA)
s3 = request.security(syminfo.tickerid, t3, trendA)
s4 = request.security(syminfo.tickerid, t4, trendA)
s5 = request.security(syminfo.tickerid, t5, trendA)
s1a = s1 == 1 ? "Bullish" : "Bearish"
s2a = s2 == 1 ? "Bullish" : "Bearish"
s3a = s3 == 1 ? "Bullish" : "Bearish"
s4a = s4 == 1 ? "Bullish" : "Bearish"
s5a = s5 == 1 ? "Bullish" : "Bearish"
// TABELS
if barstate.islast
var data_table = table.new(position=position.top_right, columns=2, rows=6, bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color, frame_color=chart.fg_color, frame_width=1)
table.cell(data_table, text_halign=text.align_center, column=0, row=0, text="Time Frame", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=0, text="Signal", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=t1, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=1, text=s1a, text_color=chart.fg_color, bgcolor=s1a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=2, text=t2, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=2, text=s2a, text_color=chart.fg_color, bgcolor=s2a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=3, text=t3, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=3, text=s3a, text_color=chart.fg_color, bgcolor=s3a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=4, text=t4, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=4, text=s4a, text_color=chart.fg_color, bgcolor=s4a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=5, text=t5, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=5, text=s5a, text_color=chart.fg_color, bgcolor=s5a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
// RETURNS
zeroLagGreen = (trendA == 1) ? true : false
zeroLagRed = (trendA == -1) ? true : false
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
smaCrossOver = ta.crossover(ta.sma(close, 20), ta.sma(close, 50))
smaCrossUnder = ta.crossunder(ta.sma(close, 20), ta.sma(close, 50))
sma20Green = ta.sma(close, 20) >= ta.sma(close, 20)[1]
sma20BreakOut = (open < ta.sma(close, 20)) and (close > ta.sma(close, 20))
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
a = 2 // input(1, title='Key Vaule. ₩'This changes the sensitivity₩'')
c = 20 // input(10, title='ATR Period')
h = false // input(false, title='Signals from Heikin Ashi Candles')
// CALCULATIONS
xATR = ta.atr(c)
nLoss = a * xATR
srcC = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = srcC > nz(xATRTrailingStop[1], 0) ? srcC - nLoss : srcC + nLoss
iff_2 = srcC < nz(xATRTrailingStop[1], 0) and srcC[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), srcC + nLoss) : iff_1
xATRTrailingStop := srcC > nz(xATRTrailingStop[1], 0) and srcC[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), srcC - nLoss) : iff_2
pos = 0
iff_3 = srcC[1] > nz(xATRTrailingStop[1], 0) and srcC < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := srcC[1] < nz(xATRTrailingStop[1], 0) and srcC > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(srcC, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = srcC > xATRTrailingStop and above
sell = srcC < xATRTrailingStop and below
barbuy = srcC > xATRTrailingStop
barsell = srcC < xATRTrailingStop
// PLOTS
// plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// RETURNS
UTBuyCond = buy ? true : false
UTSellCond = sell ? true : false
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var float entryPrice = na
var float slPrice = na
bool totalLongCond = stGreen and zeroLagGreen and (UTBuyCond or stBuySignal)
bool totalLongExitCond = stRed or zeroLagRed
if strategy.position_size == 0
if totalLongCond
pstrategy.entry("long", "strategy.long", comment = "롱 진입")
entryPrice := close
slPrice := entryPrice * (1 - slPercent)
if strategy.position_size > 0
pstrategy.exit("exit long", "long", stop = slPrice, comment = "롱 SL")
if totalLongExitCond
pstrategy.close("long", "롱 종료", immediately = true)
entryPrice := na
slPercent := na
리버피닉스
2025-07-03 23:54:01
답변 너무나 감사드립니다.
추가로 한가지 문의가 더 있어 말씀드립니다.
전에 제가 문의 드렸던 내용은
ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때, 발생하는 슈퍼트렌드 혹은 UT Bot alerts등의 신호가 발생했을시,진입을 하는 그런 전략입니다
===>이것을 ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때,===="첫번째로"==== 발생하는 슈퍼트렌드 혹은 UT Bot Alerts의 캔들을 검색하는 수식으로 수정 부탁드립니다. 녹색시그날위에 몇개의 슈퍼트렌드 혹은 Bot Alert의 신호가 발생할 때가 있는데, 첫번째 신호만 검색되도록 부탁드립니다.
감사합니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
>
안녕하세요
예스스탁입니다.
종목검색이 모든 주기에서 최대 500봉 까지 제공됩니다.
속성에서 500봉 지정하고 검색하시기 바랍니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : Periods(15);
input : Multiplier(3.0);
input : changeATR(true);
var : src(0),A1(0),atr2(0),atr1(0),atr(0);
var : up(0),up1(0),dn(0),dn1(0),trend(0);
var : buySignal(False),sellSignal(False);
var : stGreen(False),stRed(False);
var : stBuySignal(False),stSellSignal(False);
src = (h+L)/2;
A1 = 1 / periods;
atr1 = IFf(IsNan(atr1[1]) == true, ma(TrueRange,periods) , A1 * TrueRange + (1 - A1) * IFf(isnan(atr1[1])==true,0,atr1[1]));
atr2 = ma(TrueRange, Periods);
atr = iff(changeATR == true, atr1 , atr2);
up = src - Multiplier * atr;
up1 = iff(IsNan(up[1]) == true, up, up[1]);
up = iff(close[1] > up1 , max(up, up1) , up);
dn = src + Multiplier * atr;
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));
buySignal = trend == 1 and trend[1] == -1;
sellSignal = trend == -1 and trend[1] == 1;
if trend == 1 Then
stGreen = true;
Else
stGreen = false;
if trend == -1 Then
stRed = true;
Else
stRed = false;
stBuySignal = buySignal;
stSellSignal = sellSignal;
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
input : length(70);
input : mult(1.2);
var : srcA(0),lag(0),zlema(0),A3(0),atr3(0),volatility(0);
var : trendA(0),zeroLagGreen(False),zeroLagRed(False);
srcA = close;
lag = floor((length - 1) / 2);
zlema = ema(srcA + (srcA - srcA[lag]), length);
A3 = 1 / length;
atr3 = IFf(IsNan(atr3[1]) == true, ma(TrueRange,length) , A3 * TrueRange + (1 - A3) * IFf(isnan(atr3[1])==true,0,atr3[1]));
volatility = highest(atr3, length*3) * mult;
if CrossUp(close, zlema+volatility) Then
trendA = 1;
if CrossDown(close, zlema-volatility) Then
trendA = -1;
if trendA == 1 Then
zeroLagGreen = true;
Else
zeroLagGreen = False;
if trendA == -1 Then
zeroLagRed = true;
Else
zeroLagRed = False;
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
var : ma1(0),ma2(0),smaCrossOver(False),smaCrossUnder(False),sma20Green(False),sma20BreakOut(False);
ma1 = ma(C,20);
ma2 = ma(c,50);
smaCrossOver = CrossUp(ma1,ma2);
smaCrossUnder = CrossDown(ma1,ma2);
sma20Green = ma1 >= ma1[1];
sma20BreakOut = (open < ma1) and (close > ma1);
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : aa(2),cc(20),hk(False);
var : A4(0),xATR(0),nloss(0);
var : xClose(0),xOpen(0),xHigh(0),xLow(0),srcC(0);
A4 = 1 / cc;
xATR = IFf(IsNan(xATR[1]) == true, ma(TrueRange,cc) , A4 * TrueRange + (1 - A4) * IFf(isnan(xATR[1])==true,0,xATR[1]));
nLoss = aa * xATR;
#Heiken Ashi 시고저종
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) ;
}
srcC = Iff(hk == true,xclose ,close);
var : xATRTrailingStop(0),nz1(0),iff_1(0),iff_2(0),nz2(0),ps(0),iff_3(0),xcolor(0);
xATRTrailingStop = 0.0;
nz1 = iff(IsNaN(xATRTrailingStop[1]), 0,xATRTrailingStop[1]);
iff_1 = iff(srcC > nz1, srcC - nLoss , srcC + nLoss);
iff_2 = iff(srcC < nz1 and srcC[1] < nz1 , min(nz1, srcC + nLoss) , iff_1);
xATRTrailingStop = iff(srcC > nz1 and srcC[1] > nz1 , max(nz1, srcC - nLoss) , iff_2);
nz2 = iff(IsNaN(ps[1]), 0,ps[1]);
ps = 0 ;
iff_3 = iff(srcC[1] > nz1 and srcC < nz1 , -1 , nz2);
ps = iff(srcC[1] < nz1 and srcC > nz1 , 1 , iff_3);
xcolor = iff(ps == -1 , red , iff(ps == 1 , green , blue));
var : emav(0),above(False),below(False);
var : Buycond(False),Sellcond(False);
var : barbuy(False),barsell(False);
var : UTBuyCond(False),UTSellCond(False);
emav = ema(srcC, 1);
above = CrossUp(emav, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emav);
Buycond = srcC > xATRTrailingStop and above;
sellcond = srcC < xATRTrailingStop and below;
barbuy = srcC > xATRTrailingStop;
barsell = srcC < xATRTrailingStop;
// RETURNS
if buycond == true Then
UTBuyCond = true;
Else
UTBuyCond = False;
if sellcond == true Then
UTSellCond = true;
Else
UTSellCond = false;
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var : totalLongCond(False),totalLongExitCond(False);
totalLongCond = stGreen and zeroLagGreen and (UTBuyCond or stBuySignal);
totalLongExitCond = stRed or zeroLagRed;
if totalLongCond == true Then
Find(1);
즐거운 하루되세요
> 리버피닉스 님이 쓴 글입니다.
> 제목 : 아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
> 안녕하세요, 제가 트레이딩뷰 자동매매에서 사용하던 전략인데, 예스트레이더 종목검색으로 변환이 가능한지 문의 드립니다.
단순하게, ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때, 발생하는 슈퍼트렌드 혹은 UT Bot alerts등의 신호가 발생했을시,진입을 하는 그런 전략입니다. 예스트레이더의 종목검색으로 변환 가능한지 문의 드립니다. 감사합니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
Periods = 15 // input(title='ATR Period', defval=10)
src = hl2 // input(hl2, title='Source')
Multiplier = 3.0 // input.float(title='ATR Multiplier', step=0.1, defval=3.0)
changeATR = true // input(title='Change ATR Calculation Method ?', defval=true)
showsignals = true // input.bool(title='Show Buy/Sell Signals ?', defval=true, group = "SuperTrend")
highlighting = false // input.bool(title='Highlighter On/Off ?', defval=false, group = "SuperTrend")
// CALCULATIONS
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.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
// PLOTS
// upPlot = plot(trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
buySignal = trend == 1 and trend[1] == -1
// dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
sellSignal = trend == -1 and trend[1] == 1
// plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))
// plotshape(buySignal and showsignals ? up : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
// plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))
// plotshape(sellSignal and showsignals ? dn : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 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, transp=90)
// fill(mPlot, dnPlot, title='DownTrend Highligter', color=shortFillColor, transp=90)
// RETURNS
stGreen = (trend == 1) ? true : false
stRed = (trend == -1) ? true : false
stBuySignal = buySignal
stSellSignal = sellSignal
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
length = 70 // input.int(70, "Length", tooltip = "The Look-Back window for the Zero-Lag EMA calculations", group = "Main Calculations")
mult = 1.2 // input.float(1.2, "Band Multiplier", tooltip = "This value controls the thickness of the bands, a larger value makes the indicato less noisy", group = "Main Calculations")
t1 = "5" // input.timeframe("5", "Time frame 1", group = "Extra Timeframes")
t2 = "15" // input.timeframe("15", "Time frame 2", group = "Extra Timeframes")
t3 = "60" // input.timeframe("60", "Time frame 3", group = "Extra Timeframes")
t4 = "240" // input.timeframe("240", "Time frame 4", group = "Extra Timeframes")
t5 = "1D" // input.timeframe("1D", "Time frame 5", group = "Extra Timeframes")
green = #00ffbb // input.color(#00ffbb, "Bullish Color", group = "Appearance")
red = #ff1100 // input.color(#ff1100, "Bearish Color", group = "Appearance")
// CALCULATIONS
srcA = close
lag = math.floor((length - 1) / 2)
zlema = ta.ema(srcA + (srcA - srcA[lag]), length)
volatility = ta.highest(ta.atr(length), length*3) * mult
var trendA = 0
if ta.crossover(close, zlema+volatility)
trendA := 1
if ta.crossunder(close, zlema-volatility)
trendA := -1
// PLOTS
zlemaColor = trendA == 1 ? color.new(green, 70) : color.new(red, 70)
// m = plot(zlema, title="Zero Lag Basis", linewidth=2, color=zlemaColor)
// upper = plot(trendA == -1 ? zlema+volatility : na, style = plot.style_linebr, color = color.new(red, 90), title = "Upper Deviation Band")
// lower = plot(trendA == 1 ? zlema-volatility : na, style = plot.style_linebr, color = color.new(green, 90), title = "Lower Deviation Band")
// fill(m, upper, (open + close) / 2, zlema+volatility, color.new(red, 90), color.new(red, 70))
// fill(m, lower, (open + close) / 2, zlema-volatility, color.new(green, 90), color.new(green, 70))
// plotshape(ta.crossunder(trendA, 0) ? zlema+volatility : na, "Bearish Trend", shape.labeldown, location.absolute, red, text = "▼", textcolor = chart.fg_color, size = size.small)
// plotshape(ta.crossover(trendA, 0) ? zlema-volatility : na, "Bullish Trend", shape.labelup, location.absolute, green, text = "▲", textcolor = chart.fg_color, size = size.small)
// plotchar(ta.crossover(close, zlema) and trendA == 1 and trendA[1] == 1 ? zlema-volatility*1.5 : na, "Bullish Entry", "▲", location.absolute, green, size = size.tiny)
// plotchar(ta.crossunder(close, zlema) and trendA == -1 and trendA[1] == -1 ? zlema+volatility*1.5 : na, "Bearish Entry", "▼", location.absolute, red, size = size.tiny)
s1 = request.security(syminfo.tickerid, t1, trendA)
s2 = request.security(syminfo.tickerid, t2, trendA)
s3 = request.security(syminfo.tickerid, t3, trendA)
s4 = request.security(syminfo.tickerid, t4, trendA)
s5 = request.security(syminfo.tickerid, t5, trendA)
s1a = s1 == 1 ? "Bullish" : "Bearish"
s2a = s2 == 1 ? "Bullish" : "Bearish"
s3a = s3 == 1 ? "Bullish" : "Bearish"
s4a = s4 == 1 ? "Bullish" : "Bearish"
s5a = s5 == 1 ? "Bullish" : "Bearish"
// TABELS
if barstate.islast
var data_table = table.new(position=position.top_right, columns=2, rows=6, bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color, frame_color=chart.fg_color, frame_width=1)
table.cell(data_table, text_halign=text.align_center, column=0, row=0, text="Time Frame", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=0, text="Signal", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=t1, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=1, text=s1a, text_color=chart.fg_color, bgcolor=s1a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=2, text=t2, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=2, text=s2a, text_color=chart.fg_color, bgcolor=s2a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=3, text=t3, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=3, text=s3a, text_color=chart.fg_color, bgcolor=s3a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=4, text=t4, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=4, text=s4a, text_color=chart.fg_color, bgcolor=s4a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=5, text=t5, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=5, text=s5a, text_color=chart.fg_color, bgcolor=s5a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
// RETURNS
zeroLagGreen = (trendA == 1) ? true : false
zeroLagRed = (trendA == -1) ? true : false
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
smaCrossOver = ta.crossover(ta.sma(close, 20), ta.sma(close, 50))
smaCrossUnder = ta.crossunder(ta.sma(close, 20), ta.sma(close, 50))
sma20Green = ta.sma(close, 20) >= ta.sma(close, 20)[1]
sma20BreakOut = (open < ta.sma(close, 20)) and (close > ta.sma(close, 20))
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
a = 2 // input(1, title='Key Vaule. ₩'This changes the sensitivity₩'')
c = 20 // input(10, title='ATR Period')
h = false // input(false, title='Signals from Heikin Ashi Candles')
// CALCULATIONS
xATR = ta.atr(c)
nLoss = a * xATR
srcC = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = srcC > nz(xATRTrailingStop[1], 0) ? srcC - nLoss : srcC + nLoss
iff_2 = srcC < nz(xATRTrailingStop[1], 0) and srcC[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), srcC + nLoss) : iff_1
xATRTrailingStop := srcC > nz(xATRTrailingStop[1], 0) and srcC[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), srcC - nLoss) : iff_2
pos = 0
iff_3 = srcC[1] > nz(xATRTrailingStop[1], 0) and srcC < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := srcC[1] < nz(xATRTrailingStop[1], 0) and srcC > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(srcC, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = srcC > xATRTrailingStop and above
sell = srcC < xATRTrailingStop and below
barbuy = srcC > xATRTrailingStop
barsell = srcC < xATRTrailingStop
// PLOTS
// plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// RETURNS
UTBuyCond = buy ? true : false
UTSellCond = sell ? true : false
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var float entryPrice = na
var float slPrice = na
bool totalLongCond = stGreen and zeroLagGreen and (UTBuyCond or stBuySignal)
bool totalLongExitCond = stRed or zeroLagRed
if strategy.position_size == 0
if totalLongCond
pstrategy.entry("long", "strategy.long", comment = "롱 진입")
entryPrice := close
slPrice := entryPrice * (1 - slPercent)
if strategy.position_size > 0
pstrategy.exit("exit long", "long", stop = slPrice, comment = "롱 SL")
if totalLongExitCond
pstrategy.close("long", "롱 종료", immediately = true)
entryPrice := na
slPercent := na
예스스탁
예스스탁 답변
2025-07-04 10:27:04
안녕하세요
예스스탁입니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : Periods(15);
input : Multiplier(3.0);
input : changeATR(true);
var : src(0),A1(0),atr2(0),atr1(0),atr(0);
var : up(0),up1(0),dn(0),dn1(0),trend(0);
var : buySignal(False),sellSignal(False);
var : stGreen(False),stRed(False);
var : stBuySignal(False),stSellSignal(False);
src = (h+L)/2;
A1 = 1 / periods;
atr1 = IFf(IsNan(atr1[1]) == true, ma(TrueRange,periods) , A1 * TrueRange + (1 - A1) * IFf(isnan(atr1[1])==true,0,atr1[1]));
atr2 = ma(TrueRange, Periods);
atr = iff(changeATR == true, atr1 , atr2);
up = src - Multiplier * atr;
up1 = iff(IsNan(up[1]) == true, up, up[1]);
up = iff(close[1] > up1 , max(up, up1) , up);
dn = src + Multiplier * atr;
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));
buySignal = trend == 1 and trend[1] == -1;
sellSignal = trend == -1 and trend[1] == 1;
if trend == 1 Then
stGreen = true;
Else
stGreen = false;
if trend == -1 Then
stRed = true;
Else
stRed = false;
stBuySignal = buySignal;
stSellSignal = sellSignal;
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
input : length(70);
input : mult(1.2);
var : srcA(0),lag(0),zlema(0),A3(0),atr3(0),volatility(0);
var : trendA(0),zeroLagGreen(False),zeroLagRed(False);
srcA = close;
lag = floor((length - 1) / 2);
zlema = ema(srcA + (srcA - srcA[lag]), length);
A3 = 1 / length;
atr3 = IFf(IsNan(atr3[1]) == true, ma(TrueRange,length) , A3 * TrueRange + (1 - A3) * IFf(isnan(atr3[1])==true,0,atr3[1]));
volatility = highest(atr3, length*3) * mult;
if CrossUp(close, zlema+volatility) Then
trendA = 1;
if CrossDown(close, zlema-volatility) Then
trendA = -1;
if trendA == 1 Then
zeroLagGreen = true;
Else
zeroLagGreen = False;
if trendA == -1 Then
zeroLagRed = true;
Else
zeroLagRed = False;
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
var : ma1(0),ma2(0),smaCrossOver(False),smaCrossUnder(False),sma20Green(False),sma20BreakOut(False);
ma1 = ma(C,20);
ma2 = ma(c,50);
smaCrossOver = CrossUp(ma1,ma2);
smaCrossUnder = CrossDown(ma1,ma2);
sma20Green = ma1 >= ma1[1];
sma20BreakOut = (open < ma1) and (close > ma1);
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : aa(2),cc(20),hk(False);
var : A4(0),xATR(0),nloss(0);
var : xClose(0),xOpen(0),xHigh(0),xLow(0),srcC(0);
A4 = 1 / cc;
xATR = IFf(IsNan(xATR[1]) == true, ma(TrueRange,cc) , A4 * TrueRange + (1 - A4) * IFf(isnan(xATR[1])==true,0,xATR[1]));
nLoss = aa * xATR;
#Heiken Ashi 시고저종
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) ;
}
srcC = Iff(hk == true,xclose ,close);
var : xATRTrailingStop(0),nz1(0),iff_1(0),iff_2(0),nz2(0),ps(0),iff_3(0),xcolor(0);
xATRTrailingStop = 0.0;
nz1 = iff(IsNaN(xATRTrailingStop[1]), 0,xATRTrailingStop[1]);
iff_1 = iff(srcC > nz1, srcC - nLoss , srcC + nLoss);
iff_2 = iff(srcC < nz1 and srcC[1] < nz1 , min(nz1, srcC + nLoss) , iff_1);
xATRTrailingStop = iff(srcC > nz1 and srcC[1] > nz1 , max(nz1, srcC - nLoss) , iff_2);
nz2 = iff(IsNaN(ps[1]), 0,ps[1]);
ps = 0 ;
iff_3 = iff(srcC[1] > nz1 and srcC < nz1 , -1 , nz2);
ps = iff(srcC[1] < nz1 and srcC > nz1 , 1 , iff_3);
xcolor = iff(ps == -1 , red , iff(ps == 1 , green , blue));
var : emav(0),above(False),below(False);
var : Buycond(False),Sellcond(False);
var : barbuy(False),barsell(False);
var : UTBuyCond(False),UTSellCond(False);
emav = ema(srcC, 1);
above = CrossUp(emav, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emav);
Buycond = srcC > xATRTrailingStop and above;
sellcond = srcC < xATRTrailingStop and below;
barbuy = srcC > xATRTrailingStop;
barsell = srcC < xATRTrailingStop;
// RETURNS
if buycond == true Then
UTBuyCond = true;
Else
UTBuyCond = False;
if sellcond == true Then
UTSellCond = true;
Else
UTSellCond = false;
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var : count(0);
Condition1 = stGreen and zeroLagGreen;
if Condition1 == true Then
{
if Condition1[1] == False Then
count = 0;
if (UTBuyCond or stBuySignal) Then
{
count = count+1;
if count == 1 Then
Find(1);
}
}
즐거운 하루되세요
> 리버피닉스 님이 쓴 글입니다.
> 제목 : Re : Re : 아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
> 답변 너무나 감사드립니다.
추가로 한가지 문의가 더 있어 말씀드립니다.
전에 제가 문의 드렸던 내용은
ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때, 발생하는 슈퍼트렌드 혹은 UT Bot alerts등의 신호가 발생했을시,진입을 하는 그런 전략입니다
===>이것을 ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때,===="첫번째로"==== 발생하는 슈퍼트렌드 혹은 UT Bot Alerts의 캔들을 검색하는 수식으로 수정 부탁드립니다. 녹색시그날위에 몇개의 슈퍼트렌드 혹은 Bot Alert의 신호가 발생할 때가 있는데, 첫번째 신호만 검색되도록 부탁드립니다.
감사합니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
>
안녕하세요
예스스탁입니다.
종목검색이 모든 주기에서 최대 500봉 까지 제공됩니다.
속성에서 500봉 지정하고 검색하시기 바랍니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : Periods(15);
input : Multiplier(3.0);
input : changeATR(true);
var : src(0),A1(0),atr2(0),atr1(0),atr(0);
var : up(0),up1(0),dn(0),dn1(0),trend(0);
var : buySignal(False),sellSignal(False);
var : stGreen(False),stRed(False);
var : stBuySignal(False),stSellSignal(False);
src = (h+L)/2;
A1 = 1 / periods;
atr1 = IFf(IsNan(atr1[1]) == true, ma(TrueRange,periods) , A1 * TrueRange + (1 - A1) * IFf(isnan(atr1[1])==true,0,atr1[1]));
atr2 = ma(TrueRange, Periods);
atr = iff(changeATR == true, atr1 , atr2);
up = src - Multiplier * atr;
up1 = iff(IsNan(up[1]) == true, up, up[1]);
up = iff(close[1] > up1 , max(up, up1) , up);
dn = src + Multiplier * atr;
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));
buySignal = trend == 1 and trend[1] == -1;
sellSignal = trend == -1 and trend[1] == 1;
if trend == 1 Then
stGreen = true;
Else
stGreen = false;
if trend == -1 Then
stRed = true;
Else
stRed = false;
stBuySignal = buySignal;
stSellSignal = sellSignal;
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
input : length(70);
input : mult(1.2);
var : srcA(0),lag(0),zlema(0),A3(0),atr3(0),volatility(0);
var : trendA(0),zeroLagGreen(False),zeroLagRed(False);
srcA = close;
lag = floor((length - 1) / 2);
zlema = ema(srcA + (srcA - srcA[lag]), length);
A3 = 1 / length;
atr3 = IFf(IsNan(atr3[1]) == true, ma(TrueRange,length) , A3 * TrueRange + (1 - A3) * IFf(isnan(atr3[1])==true,0,atr3[1]));
volatility = highest(atr3, length*3) * mult;
if CrossUp(close, zlema+volatility) Then
trendA = 1;
if CrossDown(close, zlema-volatility) Then
trendA = -1;
if trendA == 1 Then
zeroLagGreen = true;
Else
zeroLagGreen = False;
if trendA == -1 Then
zeroLagRed = true;
Else
zeroLagRed = False;
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
var : ma1(0),ma2(0),smaCrossOver(False),smaCrossUnder(False),sma20Green(False),sma20BreakOut(False);
ma1 = ma(C,20);
ma2 = ma(c,50);
smaCrossOver = CrossUp(ma1,ma2);
smaCrossUnder = CrossDown(ma1,ma2);
sma20Green = ma1 >= ma1[1];
sma20BreakOut = (open < ma1) and (close > ma1);
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
input : aa(2),cc(20),hk(False);
var : A4(0),xATR(0),nloss(0);
var : xClose(0),xOpen(0),xHigh(0),xLow(0),srcC(0);
A4 = 1 / cc;
xATR = IFf(IsNan(xATR[1]) == true, ma(TrueRange,cc) , A4 * TrueRange + (1 - A4) * IFf(isnan(xATR[1])==true,0,xATR[1]));
nLoss = aa * xATR;
#Heiken Ashi 시고저종
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) ;
}
srcC = Iff(hk == true,xclose ,close);
var : xATRTrailingStop(0),nz1(0),iff_1(0),iff_2(0),nz2(0),ps(0),iff_3(0),xcolor(0);
xATRTrailingStop = 0.0;
nz1 = iff(IsNaN(xATRTrailingStop[1]), 0,xATRTrailingStop[1]);
iff_1 = iff(srcC > nz1, srcC - nLoss , srcC + nLoss);
iff_2 = iff(srcC < nz1 and srcC[1] < nz1 , min(nz1, srcC + nLoss) , iff_1);
xATRTrailingStop = iff(srcC > nz1 and srcC[1] > nz1 , max(nz1, srcC - nLoss) , iff_2);
nz2 = iff(IsNaN(ps[1]), 0,ps[1]);
ps = 0 ;
iff_3 = iff(srcC[1] > nz1 and srcC < nz1 , -1 , nz2);
ps = iff(srcC[1] < nz1 and srcC > nz1 , 1 , iff_3);
xcolor = iff(ps == -1 , red , iff(ps == 1 , green , blue));
var : emav(0),above(False),below(False);
var : Buycond(False),Sellcond(False);
var : barbuy(False),barsell(False);
var : UTBuyCond(False),UTSellCond(False);
emav = ema(srcC, 1);
above = CrossUp(emav, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emav);
Buycond = srcC > xATRTrailingStop and above;
sellcond = srcC < xATRTrailingStop and below;
barbuy = srcC > xATRTrailingStop;
barsell = srcC < xATRTrailingStop;
// RETURNS
if buycond == true Then
UTBuyCond = true;
Else
UTBuyCond = False;
if sellcond == true Then
UTSellCond = true;
Else
UTSellCond = false;
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var : totalLongCond(False),totalLongExitCond(False);
totalLongCond = stGreen and zeroLagGreen and (UTBuyCond or stBuySignal);
totalLongExitCond = stRed or zeroLagRed;
if totalLongCond == true Then
Find(1);
즐거운 하루되세요
> 리버피닉스 님이 쓴 글입니다.
> 제목 : 아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
> 안녕하세요, 제가 트레이딩뷰 자동매매에서 사용하던 전략인데, 예스트레이더 종목검색으로 변환이 가능한지 문의 드립니다.
단순하게, ALGOALPHA - ZERO LAG SIGNALS이 녹색일 때, 그리고 CM_ULTIMATE_MA_MTF_V2 [SMA로 대체]가 녹색(양의 값)일때, 발생하는 슈퍼트렌드 혹은 UT Bot alerts등의 신호가 발생했을시,진입을 하는 그런 전략입니다. 예스트레이더의 종목검색으로 변환 가능한지 문의 드립니다. 감사합니다.
//////////////////////////////////////////////////////////// SUPERTREND ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
Periods = 15 // input(title='ATR Period', defval=10)
src = hl2 // input(hl2, title='Source')
Multiplier = 3.0 // input.float(title='ATR Multiplier', step=0.1, defval=3.0)
changeATR = true // input(title='Change ATR Calculation Method ?', defval=true)
showsignals = true // input.bool(title='Show Buy/Sell Signals ?', defval=true, group = "SuperTrend")
highlighting = false // input.bool(title='Highlighter On/Off ?', defval=false, group = "SuperTrend")
// CALCULATIONS
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.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
// PLOTS
// upPlot = plot(trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
buySignal = trend == 1 and trend[1] == -1
// dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
sellSignal = trend == -1 and trend[1] == 1
// plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))
// plotshape(buySignal and showsignals ? up : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
// plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))
// plotshape(sellSignal and showsignals ? dn : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 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, transp=90)
// fill(mPlot, dnPlot, title='DownTrend Highligter', color=shortFillColor, transp=90)
// RETURNS
stGreen = (trend == 1) ? true : false
stRed = (trend == -1) ? true : false
stBuySignal = buySignal
stSellSignal = sellSignal
///////////////////////////////////////////////// ALGOALPHA - ZERO LAG SIGNALS /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
length = 70 // input.int(70, "Length", tooltip = "The Look-Back window for the Zero-Lag EMA calculations", group = "Main Calculations")
mult = 1.2 // input.float(1.2, "Band Multiplier", tooltip = "This value controls the thickness of the bands, a larger value makes the indicato less noisy", group = "Main Calculations")
t1 = "5" // input.timeframe("5", "Time frame 1", group = "Extra Timeframes")
t2 = "15" // input.timeframe("15", "Time frame 2", group = "Extra Timeframes")
t3 = "60" // input.timeframe("60", "Time frame 3", group = "Extra Timeframes")
t4 = "240" // input.timeframe("240", "Time frame 4", group = "Extra Timeframes")
t5 = "1D" // input.timeframe("1D", "Time frame 5", group = "Extra Timeframes")
green = #00ffbb // input.color(#00ffbb, "Bullish Color", group = "Appearance")
red = #ff1100 // input.color(#ff1100, "Bearish Color", group = "Appearance")
// CALCULATIONS
srcA = close
lag = math.floor((length - 1) / 2)
zlema = ta.ema(srcA + (srcA - srcA[lag]), length)
volatility = ta.highest(ta.atr(length), length*3) * mult
var trendA = 0
if ta.crossover(close, zlema+volatility)
trendA := 1
if ta.crossunder(close, zlema-volatility)
trendA := -1
// PLOTS
zlemaColor = trendA == 1 ? color.new(green, 70) : color.new(red, 70)
// m = plot(zlema, title="Zero Lag Basis", linewidth=2, color=zlemaColor)
// upper = plot(trendA == -1 ? zlema+volatility : na, style = plot.style_linebr, color = color.new(red, 90), title = "Upper Deviation Band")
// lower = plot(trendA == 1 ? zlema-volatility : na, style = plot.style_linebr, color = color.new(green, 90), title = "Lower Deviation Band")
// fill(m, upper, (open + close) / 2, zlema+volatility, color.new(red, 90), color.new(red, 70))
// fill(m, lower, (open + close) / 2, zlema-volatility, color.new(green, 90), color.new(green, 70))
// plotshape(ta.crossunder(trendA, 0) ? zlema+volatility : na, "Bearish Trend", shape.labeldown, location.absolute, red, text = "▼", textcolor = chart.fg_color, size = size.small)
// plotshape(ta.crossover(trendA, 0) ? zlema-volatility : na, "Bullish Trend", shape.labelup, location.absolute, green, text = "▲", textcolor = chart.fg_color, size = size.small)
// plotchar(ta.crossover(close, zlema) and trendA == 1 and trendA[1] == 1 ? zlema-volatility*1.5 : na, "Bullish Entry", "▲", location.absolute, green, size = size.tiny)
// plotchar(ta.crossunder(close, zlema) and trendA == -1 and trendA[1] == -1 ? zlema+volatility*1.5 : na, "Bearish Entry", "▼", location.absolute, red, size = size.tiny)
s1 = request.security(syminfo.tickerid, t1, trendA)
s2 = request.security(syminfo.tickerid, t2, trendA)
s3 = request.security(syminfo.tickerid, t3, trendA)
s4 = request.security(syminfo.tickerid, t4, trendA)
s5 = request.security(syminfo.tickerid, t5, trendA)
s1a = s1 == 1 ? "Bullish" : "Bearish"
s2a = s2 == 1 ? "Bullish" : "Bearish"
s3a = s3 == 1 ? "Bullish" : "Bearish"
s4a = s4 == 1 ? "Bullish" : "Bearish"
s5a = s5 == 1 ? "Bullish" : "Bearish"
// TABELS
if barstate.islast
var data_table = table.new(position=position.top_right, columns=2, rows=6, bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color, frame_color=chart.fg_color, frame_width=1)
table.cell(data_table, text_halign=text.align_center, column=0, row=0, text="Time Frame", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=0, text="Signal", text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=t1, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=1, text=s1a, text_color=chart.fg_color, bgcolor=s1a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=2, text=t2, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=2, text=s2a, text_color=chart.fg_color, bgcolor=s2a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=3, text=t3, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=3, text=s3a, text_color=chart.fg_color, bgcolor=s3a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=4, text=t4, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=4, text=s4a, text_color=chart.fg_color, bgcolor=s4a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
table.cell(data_table, text_halign=text.align_center, column=0, row=5, text=t5, text_color=chart.fg_color)
table.cell(data_table, text_halign=text.align_center, column=1, row=5, text=s5a, text_color=chart.fg_color, bgcolor=s5a == "Bullish" ? color.new(green, 70) : color.new(red, 70))
// RETURNS
zeroLagGreen = (trendA == 1) ? true : false
zeroLagRed = (trendA == -1) ? true : false
////////////////////////////////////////////// CM_ULTIMATE_MA_MTF_V2 [SMA로 대체] //////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RETURNS
smaCrossOver = ta.crossover(ta.sma(close, 20), ta.sma(close, 50))
smaCrossUnder = ta.crossunder(ta.sma(close, 20), ta.sma(close, 50))
sma20Green = ta.sma(close, 20) >= ta.sma(close, 20)[1]
sma20BreakOut = (open < ta.sma(close, 20)) and (close > ta.sma(close, 20))
//////////////////////////////////////////////////////// UT BOT ALERTS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INPUTS
a = 2 // input(1, title='Key Vaule. ₩'This changes the sensitivity₩'')
c = 20 // input(10, title='ATR Period')
h = false // input(false, title='Signals from Heikin Ashi Candles')
// CALCULATIONS
xATR = ta.atr(c)
nLoss = a * xATR
srcC = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = srcC > nz(xATRTrailingStop[1], 0) ? srcC - nLoss : srcC + nLoss
iff_2 = srcC < nz(xATRTrailingStop[1], 0) and srcC[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), srcC + nLoss) : iff_1
xATRTrailingStop := srcC > nz(xATRTrailingStop[1], 0) and srcC[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), srcC - nLoss) : iff_2
pos = 0
iff_3 = srcC[1] > nz(xATRTrailingStop[1], 0) and srcC < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := srcC[1] < nz(xATRTrailingStop[1], 0) and srcC > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(srcC, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = srcC > xATRTrailingStop and above
sell = srcC < xATRTrailingStop and below
barbuy = srcC > xATRTrailingStop
barsell = srcC < xATRTrailingStop
// PLOTS
// plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
// RETURNS
UTBuyCond = buy ? true : false
UTSellCond = sell ? true : false
/////////////////////////////////////////////////////////// STRATEGY ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var float entryPrice = na
var float slPrice = na
bool totalLongCond = stGreen and zeroLagGreen and (UTBuyCond or stBuySignal)
bool totalLongExitCond = stRed or zeroLagRed
if strategy.position_size == 0
if totalLongCond
pstrategy.entry("long", "strategy.long", comment = "롱 진입")
entryPrice := close
slPrice := entryPrice * (1 - slPercent)
if strategy.position_size > 0
pstrategy.exit("exit long", "long", stop = slPrice, comment = "롱 SL")
if totalLongExitCond
pstrategy.close("long", "롱 종료", immediately = true)
entryPrice := na
slPercent := na