커뮤니티

문의 드립니다

프로필 이미지
만강
2024-11-01 13:53:48
612
글번호 184862
답변완료
안녕하세요 트리뷰 지표전환입니다 1. length = input(14) mult = input(2) //------------------------------------------------------------------------------ upper = 0.,lower = 0.,os = 0,max = 0.,min = 0. src = close atr = ta.atr(length)*mult up = hl2 + atr dn = hl2 - atr upper := src[1] < upper[1] ? math.min(up,upper[1]) : up lower := src[1] > lower[1] ? math.max(dn,lower[1]) : dn os := src > upper ? 1 : src < lower ? 0 : os[1] spt = os == 1 ? lower : upper max := ta.cross(src,spt) ? nz(math.max(max[1],src),src) : os == 1 ? math.max(src,max[1]) : math.min(spt,max[1]) min := ta.cross(src,spt) ? nz(math.min(min[1],src),src) : os == 0 ? math.min(src,min[1]) : math.max(spt,min[1]) avg = math.avg(max,min) //------------------------------------------------------------------------------ var area_up_col = color.new(#0cb51a,80) var area_dn_col = color.new(#ff1100,80) plot0 = plot(max,'Upper Channel' ,max != max[1] and os == 1 ? na : #0cb51a) plot1 = plot(avg,'Average' ,#ff5d00) plot2 = plot(min,'Lower Channel' ,min != min[1] and os == 0 ? na : #ff1100) fill(plot0,plot1,area_up_col,'Upper Area') fill(plot1,plot2,area_dn_col,'Lower Area') 2. // Inputs a = input(1, title = "Key Vaule. 'This changes the sensitivity'") c = input(10, title = "ATR Period") h = input(false, title = "Signals from Heikin Ashi Candles") xATR = atr(c) nLoss = a * xATR src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close xATRTrailingStop = 0.0 xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss), iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss), iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss))) pos = 0 pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1, iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue ema = ema(src,1) above = crossover(ema, xATRTrailingStop) below = crossover(xATRTrailingStop, ema) buy = src > xATRTrailingStop and above sell = src < xATRTrailingStop and below barbuy = src > xATRTrailingStop barsell = src < xATRTrailingStop plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny) plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny) barcolor(barbuy ? color.green : na) barcolor(barsell ? color.red : na) alertcondition(buy, "UT Long", "UT Long") alertcondition(sell, "UT Short", "UT Short") 감사합니다
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-11-01 15:45:21

안녕하세요 예스스탁입니다. 1 input : length(14),mult(2); var : upper(0),lower(0),os(0),mx(0),mn(0); var : src(0),a(0),up(0),dn(0),spt(0),avgv(0); src = close; a = atr(length)*mult; up = (h+l)/2 + a; dn = (h+l)/2 - a; upper = iff(src[1] < upper[1] , min(up,upper[1]) , up); lower = iff(src[1] > lower[1] , max(dn,lower[1]) , dn); os = iff(src > upper , 1 , IFf(src < lower , 0 , os[1])); spt = iff(os == 1 , lower , upper); mx = iff(CrossUp(src,spt) or CrossDown(src,spt) , iff(IsNan(max(mx[1],src)) == true,src,max(mx[1],src)) , iff(os == 1 , max(src,mx[1]) , min(spt,mx[1]))); mn = iff(CrossUp(src,spt) or CrossDown(src,spt) , iff(IsNan(min(mn[1],src)) == true,src,min(mn[1],src)) , iff(os == 0 , min(src,mn[1]) , max(spt,mn[1]))); avgv = avg(mx,mn); plot1(mx,"Upper Channel"); plot2(avgv,"Average"); plot3(mn,"Lower Channel"); 2 input : aa(1),cc(10),hh(1);#1: heikinashi종가, 2: 봉종가 var : xatr(0),nloss(0),xATRTrailingStop(0); var : xOpen(0),xClose(0),xhigh(0),xlow(0),src(0),pos(0),xcolor(0),emav(0),tx(0); xATR = atr(cc); nLoss = aa * xATR; 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) ; } src = iff(hh == 1 , Xclose , close); var1 = iff(IsNan(xATRTrailingStop[1])==true, 0,xATRTrailingStop[1]); xATRTrailingStop = iff(src > var1 and src[1] > var1, max(var1, src - nLoss), iff(src < var1 and src[1] < var1, min(var1, src + nLoss), iff(src > var1, src - nLoss, src + nLoss))); pos = iff(src[1] < var1 and src > var1, 1, iff(src[1] > var1 and src < var1, -1, iff(isnan(pos[1]) == true, 0,pos[1]))); xcolor = iff(pos == -1 , red , iff(pos == 1 , green , blue)); emav = ema(src,1); Plot1(xATRTrailingStop); if src > xATRTrailingStop and CrossUp(emav, xATRTrailingStop) Then { tx = text_new(sDate,sTime,L,"Buy"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Red); } if src < xATRTrailingStop and CrossUp(xATRTrailingStop, emav) Then { tx = text_new(sDate,sTime,H,"Sell"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Red); } 즐거운 하루되세요 > 만강 님이 쓴 글입니다. > 제목 : 문의 드립니다 > 안녕하세요 트리뷰 지표전환입니다 1. length = input(14) mult = input(2) //------------------------------------------------------------------------------ upper = 0.,lower = 0.,os = 0,max = 0.,min = 0. src = close atr = ta.atr(length)*mult up = hl2 + atr dn = hl2 - atr upper := src[1] < upper[1] ? math.min(up,upper[1]) : up lower := src[1] > lower[1] ? math.max(dn,lower[1]) : dn os := src > upper ? 1 : src < lower ? 0 : os[1] spt = os == 1 ? lower : upper max := ta.cross(src,spt) ? nz(math.max(max[1],src),src) : os == 1 ? math.max(src,max[1]) : math.min(spt,max[1]) min := ta.cross(src,spt) ? nz(math.min(min[1],src),src) : os == 0 ? math.min(src,min[1]) : math.max(spt,min[1]) avg = math.avg(max,min) //------------------------------------------------------------------------------ var area_up_col = color.new(#0cb51a,80) var area_dn_col = color.new(#ff1100,80) plot0 = plot(max,'Upper Channel' ,max != max[1] and os == 1 ? na : #0cb51a) plot1 = plot(avg,'Average' ,#ff5d00) plot2 = plot(min,'Lower Channel' ,min != min[1] and os == 0 ? na : #ff1100) fill(plot0,plot1,area_up_col,'Upper Area') fill(plot1,plot2,area_dn_col,'Lower Area') 2. // Inputs a = input(1, title = "Key Vaule. 'This changes the sensitivity'") c = input(10, title = "ATR Period") h = input(false, title = "Signals from Heikin Ashi Candles") xATR = atr(c) nLoss = a * xATR src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close xATRTrailingStop = 0.0 xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss), iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss), iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss))) pos = 0 pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1, iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue ema = ema(src,1) above = crossover(ema, xATRTrailingStop) below = crossover(xATRTrailingStop, ema) buy = src > xATRTrailingStop and above sell = src < xATRTrailingStop and below barbuy = src > xATRTrailingStop barsell = src < xATRTrailingStop plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny) plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny) barcolor(barbuy ? color.green : na) barcolor(barsell ? color.red : na) alertcondition(buy, "UT Long", "UT Long") alertcondition(sell, "UT Short", "UT Short") 감사합니다