커뮤니티

변형 부탁 드립니다.

프로필 이미지
다올
2023-06-24 16:18:35
754
글번호 170057
답변완료
트레이딩뷰에서 사용되는 시스템입니다. 적용가능하도록 부탁드립니다. // 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
프로필 이미지

예스스탁 예스스탁 답변

2023-06-26 11:02:19

안녕하세요 예스스탁입니다. input : aa(1),cc(10),hh(false); var : xClose(0),xOpen(0),xHigh(0),xLow(0); var : xATR(0),nLoss(0),src(0); var : xATRTrailingStop(0),nz1(0),pov(0),nz2(0),xcolor(0); var : emav(0),above(False),Below(False); var : buycond(False),Sellcond(False),barbuy(False),barsell(False); 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 ,Xclose , close); nz1 = iff(IsNan(xATRTrailingStop[1]) == true, 0, xATRTrailingStop[1]); xATRTrailingStop = 0.0; xATRTrailingStop = iff(src > nz1 and src[1] > nz1, max(nz1,src - nLoss), iff(src < nz1 and src[1] < nz1, min(nz1, src + nLoss), iff(src > nz1, src - nLoss, src + nLoss))); nz2 = iff(IsNan(pov[1]) == true, 0, pov[1]); pov = 0 ; pov = iff(src[1] < nz1 and src > nz1, 1,iff(src[1] > nz1 and src < nz1, -1, nz2)) ; xcolor = iff(pov == -1 , red,IFf(pov == 1 , green ,blue)); emav = ema(src,1); above = CrossUp(emav, xATRTrailingStop); below = CrossDown(emav,xATRTrailingStop); buycond = src > xATRTrailingStop and above; sellcond = src < xATRTrailingStop and below; barbuy = src > xATRTrailingStop; barsell = src < xATRTrailingStop ; if Buycond Then buy("Buy"); if sellcond Then Sell("Sell"); 즐거운 하루되세요 > 다올 님이 쓴 글입니다. > 제목 : 변형 부탁 드립니다. > 트레이딩뷰에서 사용되는 시스템입니다. 적용가능하도록 부탁드립니다. // 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")