커뮤니티

안녕하세요 스크립트 해석 부탁드립니다

프로필 이미지
chancebo
2021-09-26 00:09:51
850
글번호 152464
답변완료
안녕하세요 노고에 늘 감사드립니다 트레이딩뷰 스크립트 내용이 이해가 가지 않아서 헤매고 있는데요 아래 스크립트는 어떤 상황에서 buy신호를 발생하고 또 sell 신호를 발생하는지 가능하면 설명 부탁드립니다 대단히 감사합니다 -_- //@version=3 study(title="ATR Smoothed (By dysrupt)_BuySell version", shorttitle="ATR_SM_BuySell", overlay = true) //Modifyed by @guikroth ////////////////////////////////////////////////////////////////////////////////INPUTS nATRPeriod = input(21, "Period") nATRMultip = input(6.3, "Multiplier",type=float, minval=0.5, maxval=1000, step=0.1) /////////////////////////////////////////////////////////////////////////////////ATR xATR = atr(nATRPeriod) nLoss = nATRMultip * xATR xATRTrailingStop = na xATRTrailingStop := iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss), iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss))) pos = na pos := iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1, iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) color = pos == -1 ? red: pos == 1 ? lime : blue //patr=plot(xATRTrailingStop, color=color, linewidth=2, title="ATR Trailing Stop", transp=0) // Deternine if we are currently LONG isLong = false isLong := nz(isLong[1], false) // Determine if we are currently SHORT isShort = false isShort := nz(isShort[1], false) //Trading // Buy only if the buy signal is triggered and we are not already long LONG = not isLong and pos == 1 // Sell only if the sell signal is triggered and we are not already short SHORT = not isShort and pos == -1 if (LONG) isLong := true isShort := false if (SHORT) isLong := false isShort := true barcolor(isLong ? lime : isShort ? red : na) // Show Break Alerts plotshape(SHORT, title="Sell", style=shape.labeldown, location=location.abovebar, size=size.normal, text="Sell", transp=0, textcolor = white, color=red, transp=0) plotshape(LONG, title="Buy", style=shape.labelup, location=location.belowbar, size=size.normal, text="Buy", textcolor = white, color=green, transp=0) // === /PLOTTING === // Send alert to TV alarm sub-system alertcondition(LONG,title="Sell",message="Sell") alertcondition(SHORT,title="BuY",message="Buy") alertcondition(SHORT,title="BuY",message="Buy") alertcondition(SHORT,title="BuY",message="Buy") ////////////////////////////////////////////////////////////////////////////////VWMA len2 = input(100, minval=1, title="Smooth") src = input(close, title="Source") out = vwma(src, len2) avg1=avg(out, xATRTrailingStop) plot(avg1, color=aqua, transp=0, title="ATR")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-09-27 13:56:41

안녕하세요 예스스탁입니다. 차트에 아래 지표식와 시스템 적용해 보시기 바랍니다. 종가가 해당지표를 상향돌파하면 매수, 하향이탈하면 매도하는 내용입니다. 1. 지표 input : nATRPeriod(21),nATRMultip(6.3); var : xATR(0),nloss(0),xATRTrailingStop(0); xATR = atr(nATRPeriod); nLoss = nATRMultip * xATR; xATRTrailingStop = iff(close > xATRTrailingStop[1] and close[1] > xATRTrailingStop[1], max(xATRTrailingStop[1], close - nLoss), iff(close < xATRTrailingStop[1] and close[1] < xATRTrailingStop[1], min(xATRTrailingStop[1], close + nLoss), iff(close > xATRTrailingStop[1], close - nLoss, close + nLoss))); Plot1(xATRTrailingStop); 2. 시스템 input : nATRPeriod(21),nATRMultip(6.3); var : xATR(0),nloss(0),xATRTrailingStop(0); xATR = atr(nATRPeriod); nLoss = nATRMultip * xATR; xATRTrailingStop = iff(close > xATRTrailingStop[1] and close[1] > xATRTrailingStop[1], max(xATRTrailingStop[1], close - nLoss), iff(close < xATRTrailingStop[1] and close[1] < xATRTrailingStop[1], min(xATRTrailingStop[1], close + nLoss), iff(close > xATRTrailingStop[1], close - nLoss, close + nLoss))); if CrossUp(C,xATRTrailingStop) Then Buy(); if CrossDown(C,xATRTrailingStop) Then Sell(); 즐거운 하루되세요 > chancebo 님이 쓴 글입니다. > 제목 : 안녕하세요 스크립트 해석 부탁드립니다 > 안녕하세요 노고에 늘 감사드립니다 트레이딩뷰 스크립트 내용이 이해가 가지 않아서 헤매고 있는데요 아래 스크립트는 어떤 상황에서 buy신호를 발생하고 또 sell 신호를 발생하는지 가능하면 설명 부탁드립니다 대단히 감사합니다 -_- //@version=3 study(title="ATR Smoothed (By dysrupt)_BuySell version", shorttitle="ATR_SM_BuySell", overlay = true) //Modifyed by @guikroth ////////////////////////////////////////////////////////////////////////////////INPUTS nATRPeriod = input(21, "Period") nATRMultip = input(6.3, "Multiplier",type=float, minval=0.5, maxval=1000, step=0.1) /////////////////////////////////////////////////////////////////////////////////ATR xATR = atr(nATRPeriod) nLoss = nATRMultip * xATR xATRTrailingStop = na xATRTrailingStop := iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss), iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss))) pos = na pos := iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1, iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) color = pos == -1 ? red: pos == 1 ? lime : blue //patr=plot(xATRTrailingStop, color=color, linewidth=2, title="ATR Trailing Stop", transp=0) // Deternine if we are currently LONG isLong = false isLong := nz(isLong[1], false) // Determine if we are currently SHORT isShort = false isShort := nz(isShort[1], false) //Trading // Buy only if the buy signal is triggered and we are not already long LONG = not isLong and pos == 1 // Sell only if the sell signal is triggered and we are not already short SHORT = not isShort and pos == -1 if (LONG) isLong := true isShort := false if (SHORT) isLong := false isShort := true barcolor(isLong ? lime : isShort ? red : na) // Show Break Alerts plotshape(SHORT, title="Sell", style=shape.labeldown, location=location.abovebar, size=size.normal, text="Sell", transp=0, textcolor = white, color=red, transp=0) plotshape(LONG, title="Buy", style=shape.labelup, location=location.belowbar, size=size.normal, text="Buy", textcolor = white, color=green, transp=0) // === /PLOTTING === // Send alert to TV alarm sub-system alertcondition(LONG,title="Sell",message="Sell") alertcondition(SHORT,title="BuY",message="Buy") alertcondition(SHORT,title="BuY",message="Buy") alertcondition(SHORT,title="BuY",message="Buy") ////////////////////////////////////////////////////////////////////////////////VWMA len2 = input(100, minval=1, title="Smooth") src = input(close, title="Source") out = vwma(src, len2) avg1=avg(out, xATRTrailingStop) plot(avg1, color=aqua, transp=0, title="ATR")