Convert indicator SuperTrend from the TradingView platform
Forums › ProRealTime English forum › ProBuilder support › Convert indicator SuperTrend from the TradingView platform
- This topic has 22 replies, 5 voices, and was last updated 9 months ago by ZAZI.
-
-
03/04/2024 at 12:41 PM #229195
hello guys,
Would it be possible to help me with converting the SuperTrend indicator from TradingViiew to ProRealTime code? It would be greatly appreciated.
123456789101112131415161718192021222324252627282930313233study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")Periods = input(title="ATR Period", type=input.integer, defval=10)Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)atr= atr(Periods)up=high-(Multiplier*atr)up1 = nz(up[1],up)up := close[1] > up1 ? max(up,up1) : updn=low+(Multiplier*atr)dn1 = nz(dn[1], dn)dn := close[1] < dn1 ? min(dn, dn1) : dntrend = 1trend := nz(trend[1], trend)trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trendupPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)buySignal = trend == 1 and trend[1] == -1plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)sellSignal = trend == -1 and trend[1] == 1plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.whiteshortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.whitefill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")changeCond = trend != trend[1]alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")03/04/2024 at 1:56 PM #22920003/04/2024 at 2:04 PM #22920103/05/2024 at 12:26 PM #22924203/05/2024 at 5:01 PM #229276hi
Here it is
Supertrend1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162//inputsperiods = 10 //ATR periodmultiplier = 3 //ATR multiplierchangeATR = 1 //Change ATR Calculation Method ?Showsignals = 1 //Show Buy/Sell Signals ?highlighting = 1 //Highlighter On/Off///////////////////atr = averagetruerange[periods](close)up = high - multiplier*atrup1 = up[1]if close[1] > up1 thenup = max(up,up1)elseup = upendifdn = low + multiplier*atrdn1 = dn[1]if close[1] < dn1 thendn = min(dn,dn1)elsedn = dnendifonce trend = 1if trend = -1 and close > dn1 thentrend = 1elsif trend = 1 and close < up1 thentrend = -1elsetrend = trendendifif trend = 1 thenmysupertrend = upr=0g=255b=0elsemysupertrend = dnr=255g=0b=0endifbuysignal = trend=1 and trend[1]=-1sellsignal = trend=-1 and trend[1]=1if buysignal thendrawtext("▲",barindex,mysupertrend)coloured("green")drawtext("Buy",barindex,mysupertrend-0.3*tr)coloured("green")elsif sellsignal thendrawtext("▼",barindex,mysupertrend)coloured("red")drawtext("Sell",barindex,mysupertrend+0.3*tr)coloured("red")endifmplot = (open+close+high+low)/4colorbetween(mplot,mysupertrend,r,g,b,40)return mysupertrend coloured(r,g,b)style(line,2)03/05/2024 at 11:58 PM #229286@Iván
ModeratorTHANK YOU FOR CONVERT THIS CODE, BUT AT CHART AT TRADINGWIUV THER NOT HAVE LINE WHEN CLOSE CROSS OVER RED LINE AND STARTING BUY ICON AND STARTING LONG GREEN LINE .AND SAME IN THE OPPOSITE DIRECTION WHEN CLOSE CROSS DOWN GREEN LINE AND STARTING SELL ICON AND STARTING SHORT RED LINE.03/06/2024 at 12:07 AM #22928703/06/2024 at 12:24 AM #229290What is to be deleted and why?
03/06/2024 at 12:45 AM #22929103/06/2024 at 9:53 AM #229311Please do not use ALL capital letters, as this is not considered polite according to netiquette.
Thanks 🙂
03/06/2024 at 9:55 AM #229312It must have already been deleted as I can’t find that post any longer.
03/06/2024 at 10:05 AM #22931303/06/2024 at 10:07 AM #229314Ok,thank you very much now i will know
03/10/2024 at 3:26 PM #22955003/10/2024 at 4:24 PM #229551 -
AuthorPosts
Find exclusive trading pro-tools on
Similar topics: