Traduzione codice da pinescript a prorealcode
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Traduzione codice da pinescript a prorealcode
- This topic has 2 replies, 2 voices, and was last updated 2 months ago by RubbinRubbin02.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
09/23/2024 at 1:29 PM #237939
Buongiorno, è possibile tradurre questo indicatore di divergenze RSI di tradingview da pinescript a prorealcode?
Ecco il codice:
indicator(title=”RSI Divergence Indicator”, format=format.price, timeframe=””, timeframe_gaps=true)len = input.int(title=”RSI Period”, minval=1, defval=14)src = input(title=”RSI Source”, defval=close)lbR = input(title=”Pivot Lookback Right”, defval=5, display = display.data_window)lbL = input(title=”Pivot Lookback Left”, defval=5, display = display.data_window)rangeUpper = input(title=”Max of Lookback Range”, defval=60, display = display.data_window)rangeLower = input(title=”Min of Lookback Range”, defval=5, display = display.data_window)plotBull = input(title=”Plot Bullish”, defval=true, display = display.data_window)plotHiddenBull = input(title=”Plot Hidden Bullish”, defval=false, display = display.data_window)plotBear = input(title=”Plot Bearish”, defval=true, display = display.data_window)plotHiddenBear = input(title=”Plot Hidden Bearish”, defval=false, display = display.data_window)bearColor = color.redbullColor = color.greenhiddenBullColor = color.new(color.green, 80)hiddenBearColor = color.new(color.red, 80)textColor = color.whitenoneColor = color.new(color.white, 100)osc = ta.rsi(src, len)plot(osc, title=”RSI”, linewidth=2, color=#2962FF)hline(50, title=”Middle Line”, color=#787B86, linestyle=hline.style_dotted)obLevel = hline(70, title=”Overbought”, color=#787B86, linestyle=hline.style_dotted)osLevel = hline(30, title=”Oversold”, color=#787B86, linestyle=hline.style_dotted)fill(obLevel, osLevel, title=”Background”, color=color.rgb(33, 150, 243, 90))plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : truephFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true_inRange(cond) =>bars = ta.barssince(cond == true)rangeLower <= bars and bars <= rangeUpper//——————————————————————————// Regular Bullish// Osc: Higher LowoscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])// Price: Lower LowpriceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1)bullCondAlert = priceLL and oscHL and plFoundbullCond = plotBull and bullCondAlertplot(plFound ? osc[lbR] : na,offset=-lbR,title=”Regular Bullish”,linewidth=2,color=(bullCond ? bullColor : noneColor),display = display.pane)plotshape(bullCond ? osc[lbR] : na,offset=-lbR,title=”Regular Bullish Label”,text=” Bull “,style=shape.labelup,location=location.absolute,color=bullColor,textcolor=textColor)//——————————————————————————// Hidden Bullish// Osc: Lower LowoscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])// Price: Higher LowpriceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1)hiddenBullCondAlert = priceHL and oscLL and plFoundhiddenBullCond = plotHiddenBull and hiddenBullCondAlertplot(plFound ? osc[lbR] : na,offset=-lbR,title=”Hidden Bullish”,linewidth=2,color=(hiddenBullCond ? hiddenBullColor : noneColor),display = display.pane)plotshape(hiddenBullCond ? osc[lbR] : na,offset=-lbR,title=”Hidden Bullish Label”,text=” H Bull “,style=shape.labelup,location=location.absolute,color=bullColor,textcolor=textColor)//——————————————————————————// Regular Bearish// Osc: Lower HighoscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])// Price: Higher HighpriceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1)bearCondAlert = priceHH and oscLH and phFoundbearCond = plotBear and bearCondAlertplot(phFound ? osc[lbR] : na,offset=-lbR,title=”Regular Bearish”,linewidth=2,color=(bearCond ? bearColor : noneColor),display = display.pane)plotshape(bearCond ? osc[lbR] : na,offset=-lbR,title=”Regular Bearish Label”,text=” Bear “,style=shape.labeldown,location=location.absolute,color=bearColor,textcolor=textColor)//——————————————————————————// Hidden Bearish// Osc: Higher HighoscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])// Price: Lower HighpriceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1)hiddenBearCondAlert = priceLH and oscHH and phFoundhiddenBearCond = plotHiddenBear and hiddenBearCondAlertplot(phFound ? osc[lbR] : na,offset=-lbR,title=”Hidden Bearish”,linewidth=2,color=(hiddenBearCond ? hiddenBearColor : noneColor),display = display.pane)plotshape(hiddenBearCond ? osc[lbR] : na,offset=-lbR,title=”Hidden Bearish Label”,text=” H Bear “,style=shape.labeldown,location=location.absolute,color=bearColor,textcolor=textColor)alertcondition(bullCondAlert, title=’Regular Bullish Divergence’, message=”Found a new Regular Bullish Divergence,Pivot Lookback Right
number of bars to the left of the current bar”)alertcondition(hiddenBullCondAlert, title=’Hidden Bullish Divergence’, message=’Found a new Hidden Bullish Divergence,Pivot Lookback Right
number of bars to the left of the current bar’)alertcondition(bearCondAlert, title=’Regular Bearish Divergence’, message=’Found a new Regular Bearish Divergence,Pivot Lookback Right
number of bars to the left of the current bar’)alertcondition(hiddenBearCondAlert, title=’Hidden Bearish Divergence’, message=’Found a new Hidden Bearish Divergence,Pivot Lookback Right
number of bars to the left of the current bar’)Grazie in anticipo09/24/2024 at 11:46 AM #237965Ecco qui:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107//----------------------------------------------////PRC_RSI Divergence Indicator//version = 0//24.09.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//----------------------------------------------////-----Inputs-----------------------------------////----------------------------------------------//len=14 //RSI Lengthsrc=closelbr=5 //pivot lookback Rightlbl=5 //pivot lookback LeftrangeUpper=60 //Max lookback rangerangeLower=5 //Min lookback rangeplotBull=1plotHiddenBull=1plotBear=1plotHiddenBear=1//----------------------------------------------////-----RSI Calculation--------------------------////----------------------------------------------//osc=rsi[len](src)midlevel=50obLevel=70osLevel=30colorbetween(obLevel,osLevel,33,150,243,50)//----------------------------------------------////-----Pivots High and Low----------------------////----------------------------------------------////---Pivots lowif osc > osc[lbr] and lowest[lbr](osc) > osc[lbr] and osc[lbr] < lowest[lbl](osc)[lbr+1] then$ply[z+1] = osc[lbr]$plx[z+1] = barindex[lbr]$pricel[z+1] = low[lbr]drawpoint(barindex[lbr],osc[lbr],2)coloured("red",80)z = z + 1endif//---Pivots highif osc < osc[lbr] and highest[lbr](osc)<osc[lbr] and osc[lbr]>highest[lbl](osc)[lbr+1] then$phy[t+1]=osc[lbr]$phx[t+1]=barindex[lbr]$priceH[t+1]=high[lbr]drawpoint(barindex[lbr],osc[lbr],2)coloured("blue",80)t=t+1endif//---Pivot detectionif z<>z[1] thenplFound=1elsif t<>t[1] thenphFound=1elseplFound=0phFound=0endifbarsPL=barssince(plFound[1])inrangePL=rangelower<=barsPL and barsPL<=rangeupperbarsPH=barssince(pHFound[1])inrangePH=rangelower<=barsPH and barsPH<=rangeupper//----------------------------------------------////-----Regular Bullish--------------------------////----------------------------------------------//oscHL=osc[lbr]>$ply[max(0,z-1)] and inrangePLpriceLL=low[lbr]<$pricel[max(0,z-1)]bullCondAlert=priceLL and oscHL and plFoundbullCond=plotBull and bullCondalertif plFound and bullCond thendrawsegment($plx[max(0,z-1)],$ply[max(0,z-1)],$plx[z],$ply[z])coloured("green")style(line,2)endif//----------------------------------------------////-----Hidden Bullish---------------------------////----------------------------------------------//oscLL=osc[lbr]<$ply[max(0,z-1)] and inrangePLpriceHL=low[lbr]>$pricel[max(0,z-1)]hiddenBullCondAlert=priceHL and oscLL and plFoundhiddenBullCond=hiddenBullCondAlert and plotHiddenBullif plFound and hiddenBullCond thendrawsegment($plx[max(0,z-1)],$ply[max(0,z-1)],$plx[z],$ply[z])coloured("green",80)style(line,2)endif//----------------------------------------------////-----Regular Bearish--------------------------////----------------------------------------------//oscLH=osc[lbr]<$phy[max(0,t-1)] and inrangePHpriceHH=high[lbr]>$priceH[max(0,t-1)]bearCondAlert=priceHH and oscLH and pHFoundbearCond=plotBear and bearCondalertif pHFound and bearCond thendrawsegment($phx[max(0,t-1)],$phy[max(0,t-1)],$phx[t],$phy[t])coloured("red")style(line,2)endif//----------------------------------------------////-----Hidden Bearish---------------------------////----------------------------------------------//oscHH=osc[lbr]>$phy[max(0,t-1)] and inrangePHpriceLH=high[lbr]<$priceh[max(0,t-1)]hiddenBearCondAlert=priceLH and oscHH and phFoundhiddenBearCond=hiddenBearCondAlert and plotHiddenBearif pHFound and hiddenBearCond thendrawsegment($phx[max(0,t-1)],$phy[max(0,t-1)],$phx[t],$phy[t])coloured("red",80)style(line,2)endif//----------------------------------------------//return osc as "RSI"coloured("blue")style(line,2), midlevel as "MidLevel"coloured("grey")style(dottedline,1),obLevel as "obLevel"coloured("grey")style(dottedline,1),osLevel as "osLevel"coloured("grey")style(dottedline,1)1 user thanked author for this post.
09/29/2024 at 10:43 PM #238254Grazie mille Ivan!
Posso chiederti solo una piccola modifica? Vorrei se possibile poter cambiare il colore del mio RSI e fare in modo che sia possibile settare un allarme quando viene rilevata una divergenza classica. E’ possibile?
Grazie mille in anticipo
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
Find exclusive trading pro-tools on
Similar topics: