답변완료
아래 트뷰 전략을 종목검색으로 변환 문의 드립니다.
안녕하세요, 제가 트레이딩뷰 자동매매에서 사용하던 전략인데, 예스트레이더 종목검색으로 변환이 가능한지 문의 드립니다.
단순하게, 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
285
글번호 192263
종목검색