Trend Reversal Probability
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Trend Reversal Probability
- This topic has 11 replies, 7 voices, and was last updated 3 days ago by
Ciccarelli Franco.
-
-
02/14/2025 at 3:11 PM #243846Ciao, ho visto questo indicatore che mi pare interessante e chiedo se può essere tradotto.Grazie//@version=6indicator(“Trend Reversal Probability [Algoalpha]”, “AlgoAlpha – Trend Reversal”, false, explicit_plot_zorder = true)// Inputsgroup1 = “Settings”oscPeriod = input.int(20, “Oscillator Length”, minval = 1, group=group1, tooltip=”Length for the oscillator calculation”)lvl = input.bool(true, “Enable Probability Levels”, group=group1, tooltip=”Display probability level lines on the chart”)group2 = “Colors”upColor = input.color(#00ffbb, “Up Color”, group=group2, tooltip=”Color for upward trend”)downColor = input.color(#ff1100, “Down Color”, group=group2, tooltip=”Color for downward trend”)// Amazing Oscillator CalculationmidpointPrice = hl2shortSMA = ta.sma(midpointPrice, 5)longSMA = ta.sma(midpointPrice, 34)amazingOsc = shortSMA – longSMA// RSI-like Calculationrise = ta.rma(math.max(ta.change(amazingOsc), 0), oscPeriod)fall = ta.rma(-math.min(ta.change(amazingOsc), 0), oscPeriod)customRSI = (fall == 0 ? 100 : rise == 0 ? 0 : 100 – (100 / (1 + rise / fall))) – 50opacityLevel = customRSI > 0 and customRSI > customRSI[1] or customRSI < 0 and customRSI < customRSI[1] ? 30 : 80barColor = customRSI > 0 ? color.new(upColor, opacityLevel) : color.new(downColor, opacityLevel)// Track the bar counts between crosses of customRSIvar durations = array.new_int()cut = ta.barssince(ta.cross(customRSI, 0))if cut == 0 and cut != cut[1]durations.unshift(cut[1])basis = durations.avg()col = customRSI > 0 ? upColor : downColoravg = plot(basis, title=”Average Duration”, display=lvl ? display.all : display.none, color=color.gray)upper = plot(basis + durations.stdev(), title=”Upper 1 SD”, display=lvl ? display.all : display.none, color=color.gray)upper1 = plot(basis + durations.stdev() * 2, title=”Upper 2 SD”, display=lvl ? display.all : display.none, color=color.gray)upper2 = plot(basis + durations.stdev() * 3, title=”Upper 3 SD”, display=lvl ? display.all : display.none, color=color.gray)lower = plot(basis – durations.stdev(), title=”Lower 1 SD”, display=lvl ? display.all : display.none, color=color.gray)fill(lower, upper2, basis + durations.stdev() * 3, basis – durations.stdev(), #ffe6002c, color.new(color.blue, 70))transpcon1 = 10chg1 = cut * 0.80chg2 = cut * 0.60chg3 = cut * 0.40chg4 = cut * 0.20plot(cut, title=”Signal Duration”, color=color.new(col, transpcon1 + 60), style=plot.style_columns, linewidth=4)plot(chg1, title=”Signal Duration 80%”, color=color.new(col, transpcon1 + 55), style=plot.style_columns, linewidth=4)plot(chg2, title=”Signal Duration 60%”, color=color.new(col, transpcon1 + 45), style=plot.style_columns, linewidth=4)plot(chg3, title=”Signal Duration 40%”, color=color.new(col, transpcon1 + 30), style=plot.style_columns, linewidth=4)plot(chg4, title=”Signal Duration 20%”, color=color.new(col, transpcon1 + 25), style=plot.style_columns, linewidth=4)var lab = array.new_label()while lab.size() > 0lab.shift().delete()if lvllab.push(label.new(bar_index, basis – durations.stdev(), “14%”, color=chart.fg_color, textcolor=chart.bg_color, style=label.style_label_left))lab.push(label.new(bar_index, basis, “50%”, color=chart.fg_color, textcolor=chart.bg_color, style=label.style_label_left))lab.push(label.new(bar_index, basis + durations.stdev(), “84%”, color=chart.fg_color, textcolor=chart.bg_color, style=label.style_label_left))lab.push(label.new(bar_index, basis + durations.stdev() * 2, “98%”, color=chart.fg_color, textcolor=chart.bg_color, style=label.style_label_left))lab.push(label.new(bar_index, basis + durations.stdev() * 3, “99%”, color=chart.fg_color, textcolor=chart.bg_color, style=label.style_label_left))volatility = ta.stdev(cut, 100) / 2plotchar(cut > basis + durations.stdev() * 3 ? cut + volatility : na, title=”Extreme Reversal Probability”, char=”▼”, location=location.absolute, color=color.orange, size=size.tiny)// Function to approximate cumulative probability using error functionf_cdf(z) =>a1 = 0.254829592a2 = -0.284496736a3 = 1.421413741a4 = -1.453152027a5 = 1.061405429p = 0.3275911sign = z < 0 ? -1 : 1x = math.abs(z) / math.sqrt(2)t = 1 / (1 + p * x)erf_approx = 1 – (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * math.exp(-x * x)0.5 * (1 + sign * erf_approx)z = (cut – durations.avg()) / durations.stdev()probability = f_cdf(z)var data_table = table.new(position=position.middle_right, columns=2, rows=8, bgcolor=color.new(chart.bg_color, 10), 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=”Reversal Probability (P)”, text_color=chart.fg_color, text_size=size.tiny)table.merge_cells(data_table, 0, 0, 1, 0)table.cell(data_table, text_halign=text.align_center, column=0, row=1, text=str.tostring(probability * 100, “#.#”) + “%”, text_color=chart.fg_color, text_size=size.large, bgcolor=color.from_gradient(probability, 0, 1, color.new(color.blue, 50), #ffe6002c))table.merge_cells(data_table, 0, 1, 1, 7)// Alertsalertcondition(probability > 0.84, title=”High Reversal Probability”, message=”Reversal probability crossed 84%”)alertcondition(probability > 0.98, title=”Extreme Reversal Probability”, message=”Reversal probability crossed 98%”)alertcondition(probability < 0.14, title=”Low Reversal Probability”, message=”Reversal probability below 14%”)alertcondition(cut == 0, title=”Probability Reset”, message=”Reversal probability reset”)02/15/2025 at 4:49 PM #243879
Hello, I’m really interested also to the translation of this indicator, very useful!
Ciao, sono molto interessato anche alla traduzione di questo indicatore, molto utile!02/15/2025 at 6:37 PM #243886Pubblica solo nella lingua del forum in cui stai postando. Ad esempio solo l’inglese nei forum di lingua inglese e il francese solo nei forum di lingua francese.
Grazie 🙂
02/17/2025 at 1:13 PM #243944Ciao. Eccolo qui:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135//--------------------------------------------////PRC Trend Reversal Probability//version = 0//17.02.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------//// inputs//--------------------------------------------//oscPeriod=20lvl=1 // boolean - Enable probability levels//--------------------------------------------//// Amazing Oscillator//--------------------------------------------//midpointprice=(high+low)/2shortSMA=average[5,0](midpointprice)longSMA=average[34,0](midpointprice)amazingOSC=shortSMA-longSMA//--------------------------------------------//// RSI-like//--------------------------------------------//change=amazingOSC-amazingOSC[1]//Risesrc1 = max(change,0)length = oscPeriodalpha = 1/lengthif barindex <= max(60,2*length) thenRise = average[length](src1)elseRise = alpha*src1 + (1-alpha)*Rise[1]endif//Fallsrc2 = -min(change,0)length = oscPeriodalpha = 1/lengthif barindex <= max(60,2*length) thenFall = average[length](src2)elseFall = alpha*src2 + (1-alpha)*Fall[1]endif// RSI calculationif Fall=0 thencustomRSI=100elsif Rise=0 thencustomRSI=0elsecustomRSI=100-(100/(1+rise/fall))-50endif// barcolorif customRSI>0 thenr=0g=255elser=255g=0endif//--------------------------------------------//// Track the bar counts between crosses of customRSI//--------------------------------------------//cut=barssince(customRSI crosses over 0 or customRSI crosses under 0)if cut=0 and cut<>cut[1] then$durations[z+1]=cut[1]z=z+1endif// Average CalculationsumDurations=0countValid=0for i=1 to z dosumDurations=sumDurations+$durations[i]countValid=countValid+1nextif countValid>0 thenbasis=sumDurations/countValidelsebasis=0endif// Standard Deviation CalculationsumSquaredDiffs=0for i=1 to z dosumSquaredDiffs = sumSquaredDiffs + ($durations[i] - basis) * ($durations[i] - basis)nextIF countValid > 1 THENstdDev = sqrt(sumSquaredDiffs / countValid)ELSEstdDev = 0ENDIF// Plot probability linesif lvl thenavg=basisupper=basis+stdDevupper1=basis+stdDev*2upper2=basis+stdDev*3lower=basis-stdDevendiftranspcon1=10chg1=cut*0.8chg2=cut*0.6chg3=cut*0.4chg4=cut*0.2//--------------------------------------------//// Reversal Probability//--------------------------------------------//if islastbarupdate thenk=(cut-basis)/stdDev// Error Function Approximation (erf)a1 = 0.254829592a2 = -0.284496736a3 = 1.421413741a4 = -1.453152027a5 = 1.061405429p = 0.3275911once sign = 1IF k < 0 THENsign = -1elsesign = 1ENDIFx = abs(k) / sqrt(2)t = 1 / (1 + p * x)erfApprox = 1 - (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * exp(-x * x))probability = 0.5 * (1 + sign * erfApprox)probPct=round(probability*100,1)drawtext("#probPct# %",-100,-100)anchor(topright,xshift,yshift)drawtext("Reversal Probability",-100,-80)anchor(topright,xshift,yshift)endif//--------------------------------------------//return avg as "50%" coloured("grey")style(line,2),upper as "84%" coloured("grey")style(line,2),upper1 as "98%" coloured("grey")style(line,2),upper2 as "99%" coloured("grey")style(line,2),lower as "14%" coloured("grey")style(line,2),cut as ""style(histogram)coloured(r,g,0,transpcon1+60),chg1 as ""style(histogram)coloured(r,g,0,transpcon1+55),chg2 as ""style(histogram)coloured(r,g,0,transpcon1+45),chg3 as ""style(histogram)coloured(r,g,0,transpcon1+30),chg4 as ""style(histogram)coloured(r,g,0,transpcon1+25)02/17/2025 at 6:53 PM #24395402/17/2025 at 9:05 PM #243958Hai fatto il copia e Incolla in modo errato.
Riprova, oppure importa il file ITF allegato.
02/17/2025 at 9:38 PM #24396102/17/2025 at 10:41 PM #243962Thank you so much Ivan!!!!!!!!
02/18/2025 at 9:20 AM #24396802/18/2025 at 9:50 AM #243972Ciao Ivan,
Indicatore molto bello, piccole cose sono nella lista dei desideri.
1. Ci sarà una ristampa di “Reversal Propability” quindi sarà difficile vedere il valore, vedere l’immagine allegata.
2. C’è la possibilità di ottenere etichette alla fine delle righe presenti nell’edizione originale?02/18/2025 at 10:02 AM #24397502/18/2025 at 10:30 AM #243978Si può avere uno scrinner da questo indicatore?
Grazie
-
AuthorPosts
Find exclusive trading pro-tools on