커뮤니티

지표변환 부탁드립니다~

프로필 이미지
pop700
2023-12-02 02:39:05
1147
글번호 174524
답변완료
안녕하세요~^^ 많은 도움을 주셔서 항상 감사드립니다~ 트레이딩뷰 수식인데 예스로 면환 가능하면 부탁드립니다. buy sell은 삼각형 강조표시로 부탁드립니다 indicator("Purple Cloud [MMD]",overlay=true, timeframe="", timeframe_gaps=true) atrPeriod = input(10, "Supertrend ATR Length") factor = input.float(3.0, "Supertrend Factor", step = 0.01) [supertrend, direction] = ta.supertrend(factor, atrPeriod) x1 = input(23, "Period") alpha = input.float(0.9, "Alpha", step = 0.1) x2 = ta.atr(x1) * alpha xh = close + x2 xl = close - x2 a1=ta.vwma(hl2*volume,math.ceil(x1/4))/ta.vwma(volume,math.ceil(x1/4)) a2=ta.vwma(hl2*volume,math.ceil(x1/2))/ta.vwma(volume,math.ceil(x1/2)) a3=2*a1-a2 a4=ta.vwma(a3,x1) b1 = 0.0 b1 := na(b1[1]) ? ta.sma(close, x1) : (b1[1] * (x1 - 1) + close) / x1 buy = a4<=xl and close>b1 sell = a4>=xh and close<b1 xs = 0 xs := buy ? 1 : sell ? -1 : xs[1] barcolor( color = xs==1 ? color.green :xs==-1? color.red:na) plotshape(buy and xs != xs[1] , title = "BUY", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny) plotshape(sell and xs != xs[1] , title = "SELL", text = 'S', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny) plotshape(buy and xs != xs[1] and direction < 0 , title = "Strong BUY", text = '&#128640;', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny) plotshape(sell and xs != xs[1] and direction > 0 , title = "Strong SELL", text = '&#9732;&#65039;', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny) ema200=input(false,"Ema 200") ema50=input(false,"Ema 50") ema20=input(false,"Ema 20") plot(ta.ema(close,200),color=ema200?color.black:na,title="Ema 200",linewidth = 4) plot(ta.ema(close,50),color=ema50?color.blue:na,title="EMA 50",linewidth = 3) plot(ta.ema(close,20),color=ema20?color.orange:na,title="EMA 20",linewidth = 2) alertcondition(buy and xs != xs[1], "PC Long", "PC Long") alertcondition(sell and xs != xs[1], "PC Short", "PC Short")
강조
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-12-04 11:00:43

안녕하세요 예스스탁입니다. input : atrPeriod(10); input : factor(3.0); var : hl2(0),src(0),atrv(0),direction(0),superTrend(0); var : upperBand(0),lowerBand(0); var : prevLowerBand(0),prevUpperBand(0),prevSuperTrend(0); hl2 = (H+L)/2; src = hl2; atrv = atr(atrPeriod); upperBand = src + factor * atrv; lowerBand = src - factor * atrv; prevLowerBand = iff(IsNan(lowerBand[1])==true,0,lowerBand[1]); prevUpperBand = iff(IsNan(upperBand[1])==true,0,upperBand[1]); lowerBand = iff(lowerBand > prevLowerBand or close[1] < prevLowerBand , lowerBand , prevLowerBand); upperBand = iff(upperBand < prevUpperBand or close[1] > prevUpperBand , upperBand , prevUpperBand); prevSuperTrend = superTrend[1]; if IsNan(atrv[1]) == true Then direction = 1; else if prevSuperTrend == prevUpperBand Then direction = iff(close > upperBand , -1 , 1); else direction = iff(close < lowerBand , 1 , -1); superTrend = iff(direction == -1 , lowerBand , upperBand); input : x1(23); input : alpha(0.9); var :x2(0),xh(0),xl(0); var : a1(0),a2(0),a3(0),a4(0); var : b1(0),Buycond(False),Sellcond(False); var : xs(0),tx(0); x2 = atr(x1) * alpha ; xh = close + x2; xl = close - x2 ; var1 = ma(hl2*volume * volume, Ceiling(x1/4)) / ma(volume, Ceiling(x1/4)); var2 = ma(volume * volume, Ceiling(x1/4)) / ma(volume, Ceiling(x1/4)); var3 = ma(hl2*volume * volume, Ceiling(x1/2)) / ma(volume, Ceiling(x1/2)); var4 = ma(volume * volume, Ceiling(x1/2)) / ma(volume, Ceiling(x1/2)); a1 = var1/Var2; a2 = Var3/Var4; a3 = 2*a1-a2; a4 = ma(a3*Volume, x1) / ma(volume, x1); b1 = IFf(IsNan(b1[1]) == true, ma(close, x1) , (b1[1] * (x1 - 1) + close) / x1); buycond = a4<=xl and close>b1; sellcond = a4>=xh and close<b1; xs = iff(buycond , 1 , iff(sellcond , -1 , xs[1])); if buycond and xs != xs[1] Then { tx = text_new(sDate,sTime,L,"▲"); Text_SetColor(tx,Magenta); Text_SetStyle(tx,2,0); } if sellcond and xs != xs[1] Then { tx = text_new(sDate,sTime,H,"▼"); Text_SetColor(tx,Cyan); Text_SetStyle(tx,2,1); } if buycond and xs != xs[1] and direction < 0 Then { tx = text_new(sDate,sTime,L,"▲"); Text_SetColor(tx,Red); Text_SetStyle(tx,2,0); } if sellcond and xs != xs[1] and direction > 0 Then { tx = text_new(sDate,sTime,H,"▼"); Text_SetColor(tx,Blue); Text_SetStyle(tx,2,1); } plot1(ema(close,200),"Ema 200",black); plot2(ema(close,50),"EMA 50",blue); plot3(ema(close,20),"EMA 20",orange); 즐거운 하루되세요 > pop700 님이 쓴 글입니다. > 제목 : 지표변환 부탁드립니다~ > 안녕하세요~^^ 많은 도움을 주셔서 항상 감사드립니다~ 트레이딩뷰 수식인데 예스로 면환 가능하면 부탁드립니다. buy sell은 삼각형 강조표시로 부탁드립니다 indicator("Purple Cloud [MMD]",overlay=true, timeframe="", timeframe_gaps=true) atrPeriod = input(10, "Supertrend ATR Length") factor = input.float(3.0, "Supertrend Factor", step = 0.01) [supertrend, direction] = ta.supertrend(factor, atrPeriod) x1 = input(23, "Period") alpha = input.float(0.9, "Alpha", step = 0.1) x2 = ta.atr(x1) * alpha xh = close + x2 xl = close - x2 a1=ta.vwma(hl2*volume,math.ceil(x1/4))/ta.vwma(volume,math.ceil(x1/4)) a2=ta.vwma(hl2*volume,math.ceil(x1/2))/ta.vwma(volume,math.ceil(x1/2)) a3=2*a1-a2 a4=ta.vwma(a3,x1) b1 = 0.0 b1 := na(b1[1]) ? ta.sma(close, x1) : (b1[1] * (x1 - 1) + close) / x1 buy = a4<=xl and close>b1 sell = a4>=xh and close<b1 xs = 0 xs := buy ? 1 : sell ? -1 : xs[1] barcolor( color = xs==1 ? color.green :xs==-1? color.red:na) plotshape(buy and xs != xs[1] , title = "BUY", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny) plotshape(sell and xs != xs[1] , title = "SELL", text = 'S', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny) plotshape(buy and xs != xs[1] and direction < 0 , title = "Strong BUY", text = '&#128640;', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, size = size.tiny) plotshape(sell and xs != xs[1] and direction > 0 , title = "Strong SELL", text = '&#9732;&#65039;', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny) ema200=input(false,"Ema 200") ema50=input(false,"Ema 50") ema20=input(false,"Ema 20") plot(ta.ema(close,200),color=ema200?color.black:na,title="Ema 200",linewidth = 4) plot(ta.ema(close,50),color=ema50?color.blue:na,title="EMA 50",linewidth = 3) plot(ta.ema(close,20),color=ema20?color.orange:na,title="EMA 20",linewidth = 2) alertcondition(buy and xs != xs[1], "PC Long", "PC Long") alertcondition(sell and xs != xs[1], "PC Short", "PC Short")