Traduzione codice “Indicatore di tendenza”
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Traduzione codice “Indicatore di tendenza”
- This topic has 6 replies, 3 voices, and was last updated 5 days ago by
Iván.
-
-
05/05/2025 at 10:24 AM #246802
Ivan, gentilmente puoi tradurre il codice allegato? Mi sembra interessante.
// @version= 5
indicator ( “Segnali di tendenza a ritardo zero (MTF) + Filtro laterale” , overlay = true )// === INPUT ===
// Input di tendenza a ritardo zero
lunghezza = input.int ( 70 , “Lunghezza” , gruppo = “Calcoli principali” )
mult = input.float ( 1.2 , “Moltiplicatore di banda” , gruppo = “Calcoli principali” )
t1 = input.timeframe ( “5” , “Intervallo di tempo 1” , gruppo = “Intervalli di tempo aggiuntivi” )
t2 = input.timeframe ( “15” , “Intervallo di tempo 2” , gruppo = “Intervalli di tempo aggiuntivi” )
t3 = input.timeframe ( “60” , “Intervallo di tempo 3” , gruppo = “Intervalli di tempo aggiuntivi” )
t4 = input.timeframe ( “240” , “Intervallo di tempo 4” , gruppo = “Intervalli di tempo aggiuntivi” )
t5 = input.timeframe ( “1D” , “Intervallo di tempo 5” , gruppo = “Intervalli di tempo aggiuntivi” )
verde = input.color ( #00ffbb , “Colore rialzista” , gruppo = “Aspetto” )
rosso = input.color ( #ff1100 , “Colore ribassista” , gruppo = “Aspetto” )
fillBullColor1Input = input.color ( #00ffbb , “Riempimento esterno rialzista” , gruppo = “Aspetto” )
fillBullColor2Input = input.color ( #00ffbb , “Riempimento interno rialzista” , gruppo = “Aspetto” )
fillBearColor1Input = input.color ( #ff1100 , “Riempimento esterno ribassista” , gruppo = “Aspetto” )
fillBearColor2Input = input.colore ( #ff1100 , “Riempimento interno ribassista” , gruppo = “Aspetto” )// Input di mercato laterale
rsiLength = input ( 14 , title = “Lunghezza RSI” , group = “Filtro mercato laterale” )
adxLength = input ( 14 , title = “Lunghezza ADX” , group = “Filtro mercato laterale” )
showSidewaysCircles = input.bool ( true , “Mostra cerchi laterali” , group = “Filtro mercato laterale” )
circleColor = input.color ( color.gray , “Colore cerchio laterale” , group = “Filtro mercato laterale” )// === CALCOLO DEL MERCATO LATERALE ===
rsiValue = ta.rsi ( close , rsiLength )
tr = ta.tr ( true )
upMove = high – ta.highest ( high [ 1 ] , 1 )
downMove = ta.lowest ( low [ 1 ] , 1 ) – low
diPlus = ta.rma ( upMove > downMove e upMove > 0 ? upMove : 0 , adxLength ) / ta.rma ( tr , adxLength ) * 100
diMinus = ta.rma ( downMove > upMove e downMove > 0 ? downMove : 0 , adxLength ) / ta.rma ( tr , adxLength ) * 100
dx = math.abs ( diPlus – diMinus ) / ( diPlus + diMinus ) * 100
adx = ta.rma ( dx , adxLength )
rsiCondition = rsiValue > 40 e rsiValue < 60
adxCondition = adx <= 25 e adx < diPlus e adx < diMinus
lateralmente = rsiCondition e adxCondition// Traccia il mercato lateralmente come una
forma circolare ( showSidewaysCircles e lateralmente ? chiudi : in , titolo = “Mercato Sideways” , style = shape.labelup , location = location.belowbar , color = circleColor );// === CALCOLO DEL TREND A RITARDO ZERO ===
src = close
lag = math.floor (( length – 1 ) / 2 )
zlema = ta.ema ( src + ( src – src [ lag ]) , length )
volatility = ta.highest ( ta.atr ( length ) , length * 3 ) * mult
var trend = 0se non lateralmente se ta.crossover ( chiusura , zlema + volatilità ) tendenza : = 1 altrimenti se ta.crossunder ( chiusura , zlema – volatilità ) tendenza : = -1
zlemaColor = trend == 1 ? color.new ( verde , 70 ) : trend == -1 ? color.new ( rosso , 70 ) : na
m = plot ( zlema , titolo = “Base a ritardo zero” , larghezza riga = 2 , colore = zlemaColor )
superiore = plot ( trend == -1 ? zlema + volatilità : na , stile = plot.style_linebr , colore = color.new ( rosso , 90 ) , titolo = “Banda di deviazione superiore” )
inferiore = plot ( trend == 1 ? zlema – volatilità : na , stile = plot.style_linebr , colore = color.new ( verde , 90 ) , titolo = “Banda di deviazione inferiore” )riempimento ( m , superiore , ( apri + chiudi ) / 2 , zlema + volatilità , colore.nuovo ( fillBearColor1Input , 90 ) , colore.nuovo ( fillBearColor2Input , 70 ))
riempimento ( m , inferiore , ( apri + chiudi ) / 2 , zlema – volatilità , colore.nuovo ( fillBullColor1Input , 90 ) , colore.nuovo ( fillBullColor2Input , 70 ))plotshape ( non lateralmente e ta.crossover ( trend , 0 ) ? zlema + volatilità : na , “Trend ribassista” , shape.labeldown , location.absolute , rosso , testo = “▼” , colore del testo = chart.fg_color , dimensione = size.small )
plotshape ( non lateralmente e ta.crossover ( trend , 0 ) ? zlema – volatilità : na , “Trend rialzista” , shape.labelup , location.absolute , verde , testo = “▲” , colore del testo = chart.fg_color , dimensione = size.small )plotchar ( non lateralmente e ta.crossover ( chiudi , zlema ) e trend == 1 e trend [ 1 ] == 1 ? zlema – volatilità * 1,5 : na , “Entrata rialzista” , “▲” , posizione.assoluta , verde , dimensione = dimensione.piccola )
plotchar ( non lateralmente e ta.crossunder ( chiudi , zlema ) e trend == -1 e trend [ 1 ] == -1 ? zlema + volatilità * 1,5 : na , “Entrata ribassista” , “▼” , posizione.assoluta , rosso , dimensione = dimensione.piccola )s1 = richiesta.sicurezza ( syminfo.tickerid , t1 , tendenza )
s2 = richiesta.sicurezza ( syminfo.tickerid , t2 , tendenza )
s3 = richiesta.sicurezza ( syminfo.tickerid , t3 , tendenza )
s4 = richiesta.sicurezza ( syminfo.tickerid , t4 , tendenza )
s5 = richiesta.sicurezza ( syminfo.tickerid , t5 , tendenza )s1a = s1 == 1 ? “Rialzista” : “Ribassista”
s2a = s2 == 1 ? “Rialzista” : “Ribassista”
s3a = s3 == 1 ? “Rialzista” : “Ribassista”
s4a = s4 == 1 ? “Rialzista” : “Ribassista”
s5a = s5 == 1 ? “Rialzista” : “Ribassista”se barstate.islast var data_table = table.new ( posizione = position.top_right , colonne = 2 , righe = 6 , colore sfondo = chart.bg_color , larghezza bordo = 1 , colore bordo = chart.fg_color , colore cornice = chart.fg_color , larghezza cornice = 1 ) table.cell ( data_table , text_halign = text.align_center , colonna = 0 , riga = 0 , testo = “Intervallo di tempo” , colore testo = chart.fg_color ) table.cell ( data_table , text_halign = text.align_center , colonna = 1 , riga = 0 , testo = “Segnale” , colore testo = chart.fg_color )
table.cell ( data_table , text_halign = text.align_center , column = 0 , row = 1 , text = t1 , text_color = chart.fg_color ) table.cell ( data_table , text_halign = text.align_center , column = 1 , row = 1 , text = s1a , text_color = chart.fg_color , bgcolor = s1a == “Ottimista” ? color.new ( green , 70 ) : color.new ( red , 70 ))
table.cell ( data_table , text_halign = text.align_center , column = 0 , row = 2 , text = t2 , text_color = chart.fg_color ) table.cell ( data_table , text_halign = text.align_center , column = 1 , row = 2 , text = s2a , text_color = chart.fg_color , bgcolor = s2a == “Ottimista” ? color.new ( green , 70 ) : color.new ( red , 70 ))
table.cell ( data_table , text_halign = text.align_center , column = 0 , row = 3 , text = t3 , text_color = chart.fg_color ) table.cell ( data_table , text_halign = text.align_center , column = 1 , row = 3 , text = s3a , text_color = chart.fg_color , bgcolor = s3a == “Ottimista” ? color.new ( green , 70 ) : color.new ( red , 70 ))
table.cell ( data_table , text_halign = text.align_center , column = 0 , row = 4 , text = t4 , text_color = chart.fg_color ) table.cell ( data_table , text_halign = text.align_center , column = 1 , row = 4 , text = s4a , text_color = chart.fg_color , bgcolor = s4a == “Ottimista” ? color.new ( green , 70 ) : color.new ( red , 70 ))
table.cell ( data_table , text_halign = text.align_center , column = 0 , row = 5 , text = t5 , text_color = chart.fg_color ) table.cell ( data_table , text_halign = text.align_center , column = 1 , row = 5 , text = s5a , text_color = chart.fg_color , bgcolor = s5a == “Ottimista” ? color.new ( green , 70 ) : color.new ( red , 70 ))
// === AVVISI ===
alertcondition ( non laterale e ta.crossover ( close , zlema ) e trend == 1 e trend [ 1 ] == 1 , “Segnale di ingresso rialzista” , message = “Segnale di ingresso rialzista rilevato. Si consideri l’inserimento di una posizione lunga.” )
alertcondition ( non laterale e ta.crossunder ( close , zlema ) e trend == -1 e trend [ 1 ] == -1 , “Segnale di ingresso ribassista” , message = “Segnale di ingresso ribassista rilevato. Si consideri l’inserimento di una posizione corta.” )
alertcondition ( non laterale e ta.crossover ( trend , 0 ) , “Tendenza rialzista” )
alertcondition ( non laterale e ta.crossunder ( trend , 0 ) , “Tendenza ribassista” )
alertcondition ( non laterale e ta.cross ( trend , 0 ) , “Tendenza (rialzista o ribassista)” )Grazie
05/05/2025 at 2:11 PM #246811Ciao. Posso tradurlo, ma ho bisogno di un codice funzionante. Quello che hai fornito sembra una traduzione dall’inglese all’italiano e contiene diversi errori.
Se mi fornisci il codice funzionante e, soprattutto, lo aggiungi con il pulsante “Add PRT code”, posso farlo.05/05/2025 at 5:37 PM #246819Salvo errori, c’è già questa versione senza tabella timeframes:
https://www.prorealcode.com/topic/zero-lag-trend-signals-indicator-by-algoalpha/
05/05/2025 at 5:43 PM #246820123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106//@version=5indicator(""Zero Lag Trend Signals (MTF) + Sideways Filter"", overlay=true)// === INPUTS ===// Zero Lag Trend Inputslength = input.int(70, ""Length"", group = ""Main Calculations"")mult = input.float(1.2, ""Band Multiplier"", group = ""Main Calculations"")t1 = input.timeframe(""5"", ""Time frame 1"", group = ""Extra Timeframes"")t2 = input.timeframe(""15"", ""Time frame 2"", group = ""Extra Timeframes"")t3 = input.timeframe(""60"", ""Time frame 3"", group = ""Extra Timeframes"")t4 = input.timeframe(""240"", ""Time frame 4"", group = ""Extra Timeframes"")t5 = input.timeframe(""1D"", ""Time frame 5"", group = ""Extra Timeframes"")green = input.color(#00ffbb, ""Bullish Color"", group = ""Appearance"")red = input.color(#ff1100, ""Bearish Color"", group = ""Appearance"")fillBullColor1Input = input.color(#00ffbb, ""Bullish Fill Outer"", group = ""Appearance"")fillBullColor2Input = input.color(#00ffbb, ""Bullish Fill Inner"", group = ""Appearance"")fillBearColor1Input = input.color(#ff1100, ""Bearish Fill Outer"", group = ""Appearance"")fillBearColor2Input = input.color(#ff1100, ""Bearish Fill Inner"", group = ""Appearance"")// Sideways Market InputsrsiLength = input(14, title=""RSI Length"", group=""Sideways Market Filter"")adxLength = input(14, title=""ADX Length"", group=""Sideways Market Filter"")showSidewaysCircles = input.bool(true, ""Show Sideways Circles"", group=""Sideways Market Filter"")circleColor = input.color(color.gray, ""Sideways Circle Color"", group=""Sideways Market Filter"")// === SIDEWAYS MARKET CALCULATION ===rsiValue = ta.rsi(close, rsiLength)tr = ta.tr(true)upMove = high - ta.highest(high[1], 1)downMove = ta.lowest(low[1], 1) - lowdiPlus = ta.rma(upMove > downMove and upMove > 0 ? upMove : 0, adxLength) / ta.rma(tr, adxLength) * 100diMinus = ta.rma(downMove > upMove and downMove > 0 ? downMove : 0, adxLength) / ta.rma(tr, adxLength) * 100dx = math.abs(diPlus - diMinus) / (diPlus + diMinus) * 100adx = ta.rma(dx, adxLength)rsiCondition = rsiValue > 40 and rsiValue < 60adxCondition = adx <= 25 and adx < diPlus and adx < diMinussideways = rsiCondition and adxCondition// Plot sideways market as a circleplotshape(showSidewaysCircles and sideways ? close : na, title=""Sideways Market"", style=shape.labelup, location=location.belowbar, color=circleColor)// === ZERO LAG TREND CALCULATION ===src = closelag = math.floor((length - 1) / 2)zlema = ta.ema(src + (src - src[lag]), length)volatility = ta.highest(ta.atr(length), length * 3) * multvar trend = 0if not sidewaysif ta.crossover(close, zlema + volatility)trend := 1else if ta.crossunder(close, zlema - volatility)trend := -1zlemaColor = trend == 1 ? color.new(green, 70) : trend == -1 ? color.new(red, 70) : nam = plot(zlema, title=""Zero Lag Basis"", linewidth=2, color=zlemaColor)upper = plot(trend == -1 ? zlema + volatility : na, style=plot.style_linebr, color=color.new(red, 90), title=""Upper Deviation Band"")lower = plot(trend == 1 ? zlema - volatility : na, style=plot.style_linebr, color=color.new(green, 90), title=""Lower Deviation Band"")fill(m, upper, (open + close) / 2, zlema + volatility, color.new(fillBearColor1Input, 90), color.new(fillBearColor2Input, 70))fill(m, lower, (open + close) / 2, zlema - volatility, color.new(fillBullColor1Input, 90), color.new(fillBullColor2Input, 70))plotshape(not sideways and ta.crossunder(trend, 0) ? zlema + volatility : na, ""Bearish Trend"", shape.labeldown, location.absolute, red, text=""▼"", textcolor=chart.fg_color, size=size.small)plotshape(not sideways and ta.crossover(trend, 0) ? zlema - volatility : na, ""Bullish Trend"", shape.labelup, location.absolute, green, text=""▲"", textcolor=chart.fg_color, size=size.small)plotchar(not sideways and ta.crossover(close, zlema) and trend == 1 and trend[1] == 1 ? zlema - volatility * 1.5 : na, ""Bullish Entry"", ""▲"", location.absolute, green, size=size.tiny)plotchar(not sideways and ta.crossunder(close, zlema) and trend == -1 and trend[1] == -1 ? zlema + volatility * 1.5 : na, ""Bearish Entry"", ""▼"", location.absolute, red, size=size.tiny)s1 = request.security(syminfo.tickerid, t1, trend)s2 = request.security(syminfo.tickerid, t2, trend)s3 = request.security(syminfo.tickerid, t3, trend)s4 = request.security(syminfo.tickerid, t4, trend)s5 = request.security(syminfo.tickerid, t5, trend)s1a = s1 == 1 ? ""Bullish"" : ""Bearish""s2a = s2 == 1 ? ""Bullish"" : ""Bearish""s3a = s3 == 1 ? ""Bullish"" : ""Bearish""s4a = s4 == 1 ? ""Bullish"" : ""Bearish""s5a = s5 == 1 ? ""Bullish"" : ""Bearish""if barstate.islastvar data_table = table.new(position=position.top_right, columns=2, rows=6, bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color, frame_color=chart.fg_color, frame_width=1)table.cell(data_table, text_halign=text.align_center, column=0, row=0, text=""Time Frame"", text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=1, row=0, text=""Signal"", text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=t1, text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=1, row=1, text=s1a, text_color=chart.fg_color, bgcolor=s1a == ""Bullish"" ? color.new(green, 70) : color.new(red, 70))table.cell(data_table, text_halign=text.align_center, column=0, row=2, text=t2, text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=1, row=2, text=s2a, text_color=chart.fg_color, bgcolor=s2a == ""Bullish"" ? color.new(green, 70) : color.new(red, 70))table.cell(data_table, text_halign=text.align_center, column=0, row=3, text=t3, text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=1, row=3, text=s3a, text_color=chart.fg_color, bgcolor=s3a == ""Bullish"" ? color.new(green, 70) : color.new(red, 70))table.cell(data_table, text_halign=text.align_center, column=0, row=4, text=t4, text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=1, row=4, text=s4a, text_color=chart.fg_color, bgcolor=s4a == ""Bullish"" ? color.new(green, 70) : color.new(red, 70))table.cell(data_table, text_halign=text.align_center, column=0, row=5, text=t5, text_color=chart.fg_color)table.cell(data_table, text_halign=text.align_center, column=1, row=5, text=s5a, text_color=chart.fg_color, bgcolor=s5a == ""Bullish"" ? color.new(green, 70) : color.new(red, 70))// === ALERTS ===alertcondition(not sideways and ta.crossover(close, zlema) and trend == 1 and trend[1] == 1, ""Bullish Entry Signal"", message=""Bullish Entry Signal detected. Consider entering a long position."")alertcondition(not sideways and ta.crossunder(close, zlema) and trend == -1 and trend[1] == -1, ""Bearish Entry Signal"", message=""Bearish Entry Signal detected. Consider entering a short position."")alertcondition(not sideways and ta.crossover(trend, 0), ""Bullish Trend"")alertcondition(not sideways and ta.crossunder(trend, 0), ""Bearish Trend"")alertcondition(not sideways and ta.cross(trend, 0), ""(Bullish or Bearish) Trend"")05/06/2025 at 8:24 AM #246830Adesso sì!
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889//-------------------------------------////PRC_Zero Lag Trend Signals + Sideways filter//version = 0//06.05.25//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------////---Inputs//-------------------------------------//length=70mult=1.2src=closersilength=14adxlength=14showSideways=1//-------------------------------------//// Sideways market calculation//-------------------------------------////---RSIrsivalue=rsi[rsilength](close)rsiCondition=rsiValue>40 and rsiValue<60//---ADXpdi=DIplus[adxlength](close)mdi=DIminus[adxlength](close)iadx=ADX[adxlength]adxCondition=iadx<=25 and iadx<pdi and iadx<mdi//---Sidewayssideways=rsiCondition and adxConditionif showSideways and sideways thendrawpoint(barindex,low-tr,2)coloured("grey")endif//-------------------------------------//// Zlema calculation//-------------------------------------//lag=floor((length-1)/2)myzlema=average[length,1](src+(src-src[lag]))//-------------------------------------//// Volatility calculation//-------------------------------------//atr=averagetruerange[length](close)volatil=highest[length*3](atr)*mult//-------------------------------------//// Trend condition//-------------------------------------//once trend=0if sideways=0 thenif close crosses over myzlema+volatil thentrend=1r=0g=255elsif close crosses under myzlema-volatil thentrend=-1r=255g=0endifendif//-------------------------------------//// Signals and colors//-------------------------------------//if trend=-1 thenupper=myzlema+volatilalpha1=90lower=myzlemaalpha2=0if trend<>trend[1] and sideways=0 thendrawarrowdown(barindex,upper+0.25*atr)coloured(r,g,0,175)endifelseupper=myzlemaalpha1=0lower=myzlema-volatilalpha2=90if trend<>trend[1] and sideways=0 thendrawarrowup(barindex,lower-0.25*atr)coloured(r,g,0,175)endifendifif close crosses over myzlema and trend=1 and trend[1]=1 and sideways=0 thendrawtext("▲",barindex,myzlema-volatil*1.5)coloured("green")elsif close crosses under myzlema and trend=-1 and trend[1]=-1 and sideways=0 thendrawtext("▼",barindex,myzlema+volatil*1.5)coloured("red")endifif barindex > 4*length thencolorbetween(myzlema,upper,r,g,0,alpha1)colorbetween(myzlema,lower,r,g,0,alpha2)endif//-------------------------------------//return myzlema as "Zero Lag Basis"style(line,2)coloured(r,g,0)05/06/2025 at 8:56 AM #246832Grazie funziona bene, ma non ci sono etichette sui vari TF
05/06/2025 at 9:23 AM #246833 -
AuthorPosts
Find exclusive trading pro-tools on