커뮤니티
트레이딩뷰 지표 변환
트레이딩뷰 지표를 im증권예스트레이더 지표로 만들려고합니다
//@version=6
indicator('EMA Signal', overlay = true, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500, format = format.price, precision = 2)
// === Inputs ===
sensitivity = input(9, title = 'Sensitivity')
atrPeriod = input(100, title = 'ATR Period')
useHeikinAshi = false // fixed setting
// === ATR Calculation ===
atr = ta.atr(atrPeriod)
nLoss = sensitivity * atr
// === Price Source (Heikin Ashi or Regular) ===
haSymbol = syminfo.tickerid + ':heikinashi'
priceSource = request.security(useHeikinAshi ? haSymbol : syminfo.tickerid,
timeframe.period, close)
// === ATR Trailing Stop Logic ===
atrStop = 0.0
atrStop := if priceSource > nz(atrStop[1], 0) and priceSource[1] > nz(atrStop[1], 0)
math.max(nz(atrStop[1]), priceSource - nLoss)
else if priceSource < nz(atrStop[1], 0) and priceSource[1] < nz(atrStop[1], 0)
math.min(nz(atrStop[1]), priceSource + nLoss)
else
priceSource > nz(atrStop[1], 0) ? priceSource - nLoss : priceSource + nLoss
// === Position State ===
position = 0
position := if priceSource[1] < nz(atrStop[1], 0) and priceSource > nz(atrStop[1], 0)
1
else if priceSource[1] > nz(atrStop[1], 0) and priceSource < nz(atrStop[1], 0)
-1
else
nz(position[1], 0)
// === Color by Position ===
trendColor = position == -1 ? color.red :
position == 1 ? color.green : color.blue
// === EMA of ATR Trail ===
atrEma = ta.ema(priceSource, 1)
crossAbove = ta.crossover(atrEma, atrStop)
crossBelow = ta.crossover(atrStop, atrEma)
// === Buy/Sell Signal Conditions ===
buySignal = priceSource > atrStop and crossAbove
sellSignal = priceSource < atrStop and crossBelow
// === Signal Visuals ===
plotshape(buySignal,
title = 'Buy Signal',
location = location.belowbar,
style = shape.labelup,
color = color.rgb(128, 128, 128),
text = 'EMA BuySignal',
textcolor = color.rgb(0, 0, 0),
size = size.small)
plotshape(sellSignal,
title = 'Sell Signal',
location = location.abovebar,
style = shape.labeldown,
color = color.rgb(128, 128, 128),
text = 'EMA SellSignal',
textcolor = color.rgb(0, 0, 0),
size = size.small)
// === Bar Coloring ===
barcolor(priceSource > atrStop ? color.new(color.green, 0) : na)
barcolor(priceSource < atrStop ? color.new(color.red, 0) : na)
// === Trend EMA Overlay ===
trendEmaLength = input.int(100, title = 'Trend EMA Length')
trendEmaColor = input.color(#cfcfc6, title = 'Trend EMA Color')
trendEmaWidth = input.int(3, title = 'Trend EMA Width')
trendEma = ta.ema(close, trendEmaLength)
plot(trendEma,
color = trendEmaColor,
linewidth = math.max(1, trendEmaWidth),
title = 'Trend EMA')
// === Alerts ===
alertcondition(buySignal, title = 'Buy Alert', message = 'Buy Signal')
alertcondition(sellSignal, title = 'Sell Alert', message = 'Sell Signal')
답변 1
예스스탁 예스스탁 답변
2026-05-28 10:25:37