커뮤니티

트레이딩뷰 지표 변환

프로필 이미지
기도니
2026-05-27 16:55:13
23
글번호 232171
답변완료

트레이딩뷰 지표를 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

안녕하세요 예스스탁입니다. input : sensitivity(9); input : atrPeriod(100); input : useHeikinAshi(false); var : alpha(0),atrv(0),nloss(0),priceSource(0),atrStop(0),position(0); alpha = 1 / atrPeriod ; atrv = IFf(IsNan(ATRV[1]) == true, ma(TrueRange,atrPeriod) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRV[1])==true,0,ATRV[1])); nLoss = sensitivity * atrv; if useHeikinAshi == true Then priceSource = (O+H+L+C)/4; Else priceSource = close; // === ATR Trailing Stop Logic === atrStop = 0.0; if priceSource > IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) and priceSource[1] > iff(IsNan(atrStop[1])==true, 0,atrStop[1]) Then atrStop = max(IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]), priceSource - nLoss); else if priceSource < IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) and priceSource[1] < IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) Then atrStop = min(IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]), priceSource + nLoss); else atrStop = iff(priceSource > IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) , priceSource - nLoss , priceSource + nLoss); // === Position State === position = 0; if priceSource[1] < IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) and priceSource > IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) Then position= 1; else if priceSource[1] > IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) and priceSource < IFF(IsNan(atrStop[1]) ==true, 0,atrStop[1]) Then position= -1; else position= iff(IsNan(position[1]) == true, 0,position[1]); var : trendcolor(0),atrEma(0),crossAbove(False),crossBelow(False); var : buySignal(False),SellSignal(False),tx(0); trendColor = iff(position == -1 , red , IFf(position == 1 , green ,blue)); atrEma = ema(priceSource, 1); crossAbove = CrossUp(atrEma, atrStop); crossBelow = CrossUp(atrStop, atrEma); buySignal = priceSource > atrStop and crossAbove; sellSignal = priceSource < atrStop and crossBelow; if BuySignal == true Then { tx = text_new(sDate,sTime,L,"▲"); Text_SetColor(tx,rgb(128, 128, 128)); Text_SetSize(tx,20); Text_SetStyle(Tx,2,0); } if sellSignal == true Then { tx = text_new(sDate,sTime,H,"▼"); Text_SetColor(tx,rgb(128, 128, 128)); Text_SetSize(tx,20); Text_SetStyle(Tx,2,1); } // === Trend EMA Overlay === input : trendEmaLength(100); input : trendEmaColor(Silver); input : trendEmaWidth(3); var : trendEma(0); trendEma = ema(close, trendEmaLength); plot1(trendEma,"Trend EMA", trendEmaColor,Def, max(1, trendEmaWidth)); 즐거운 하루되세요