Conversion of Dynamic Flow Ribbons and of Deviation Trend Profile of Tradingview
Forums › ProRealTime forum Français › Support ProBuilder › Conversion of Dynamic Flow Ribbons and of Deviation Trend Profile of Tradingview
- This topic has 1 reply, 2 voices, and was last updated 1 week ago by
Iván.
-
-
07/03/2025 at 2:44 PM #248652
Bonjour,
J’ai trouvé deux excellents indicateurs sur TradingView. J’ai du mal à le traduire. Si vous ne pouvez en traduire seulement un seul, ca me va.
Ce sont les Dynamic Flow Ribbons et le Deviation Trend Profile. Les 2 viennent de BigBeluga, je vois mets le code ci dessous
Quelqu’un peut-il m’aider ?
Merci d’avance
CordialementHello,
I have found 2 such great indicators on TradingView. I got difficulties to translate it. If you can only translate one of them, it is okay, better one than nothing
It is the Dynamic Flow Ribbons and the Deviation Trend Profile, both of BigBeluga, i will let you the code below.
Can someone help me ?
ThanksKinds Regards
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// https://creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
//@version=6
indicator(“Deviation Trend Profile [BigBeluga]”, overlay = true, max_boxes_count = 500, max_bars_back = 5000)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
grp = “Standart Deviation Levels”
length = input.int(50, “SMA Length”, group = “SMA”)
mult1 = input.int(1, “Standart Deviation 1”, group = grp)
mult2 = input.int(2, “Standart Deviation 2”, group = grp)
mult3 = input.int(3, “Standart Deviation 3”, group = grp)
show_tp = input.bool(true, “Show”, group = “Trend Distribution Profile”)
bins = input.int(50, “Bins Amount”, group = “Trend Distribution Profile”)
offset = input.int(30, “Offset”, group = “Trend Distribution Profile”)
col_up = input.color(color.rgb(18, 209, 235), “”, group = “Theme”, inline = “c”)
col_dn = input.color(color.rgb(250, 40, 86), “”, group = “Theme”, inline = “c”)
var start_index = int(na)
var trend = bool(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
avg = ta.sma(close, length)
atr = ta.atr(200)
stdv1 = avg + atr * mult1
stdv2 = avg + atr * mult2
stdv3 = avg + atr * mult3
stdv_1 = avg – atr * mult1
stdv_2 = avg – atr * mult2
stdv_3 = avg – atr * mult3
max = stdv3
min = stdv_3
avg_diff = avg – avg[5]
avg_col = avg_diff / ta.percentile_linear_interpolation(avg_diff, 500, 100)
avg_color = color.from_gradient(avg_col, -0.3, 0.3, col_dn, col_up)
if ta.crossover(avg_col, 0.1) and not trend
trend := true
start_index := bar_index
if ta.crossunder(avg_col, -0.1) and trend
trend := false
start_index := bar_index
loockback = bar_index – start_index
profile(min, max)=>
var boxes = array.new()
var bin = array.new(bins)
step = (max – min) / bins
start = bar_index + offset
if barstate.islast
if boxes.size() >=0
for b in boxes
box.delete(b)
for g = 0 to bins-1
bin.set(g, 0)
for l = 0 to loockback
c = close[l]
a = avg[l]
mi = min[l]
s = step[l]
for i = 0 to bin.size()-1
lower = mi + s * i
upper = lower + s
if c >= lower-s and c <= upper+s bin.set(i, bin.get(i) + 1) for j = 0 to bin.size()-1 val = bin.get(j) lower = min + step * j upper = lower + step col = color.from_gradient(val, 0, bin.max(), color.new(chart.fg_color, 80), avg_color) boxes.push(box.new(start-val, upper, start, lower, bgcolor = col, border_color = val == 0 ? chart.fg_color : chart.bg_color)) label.delete(label.new(start, max, str.tostring(loockback), textcolor = chart.fg_color, color = color.new(avg_color, 80), tooltip = str.tostring(loockback) + " bars back beginnig of the trend")[1]) draw_stdv(src, mult, mid = false)=>
if barstate.islast
if mid
line.delete(line.new(bar_index, avg, bar_index+5, avg, color = avg_color, width = 2)[1])
line.delete(line.new(bar_index, src, bar_index+5, src, color = chart.fg_color, width = 2)[1])
label.delete(label.new(bar_index+5, src, color = color.new(chart.fg_color, 100), textcolor = chart.fg_color, text = mult, style = label.style_label_left)[1])
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
draw_stdv(stdv1, “+1”, true)
draw_stdv(stdv2, “+2”)
draw_stdv(stdv3, “+3”)
draw_stdv(stdv_1, “-1”)
draw_stdv(stdv_2, “-2”)
draw_stdv(stdv_3, “-3”)
if show_tp
profile(min, max)
plot(avg, color = avg_color, linewidth = 3)
plotshape(trend != trend[1] and trend ? avg : na, “Up”, shape.circle, location.absolute, size = size.tiny, color = col_up)
plotshape(trend != trend[1] and trend ? avg : na, “Up”, shape.circle, location.absolute, size = size.small, color = color.new(col_up, 50))
plotshape(trend != trend[1] and not trend ? avg : na, “Down”, shape.circle, location.absolute, size = size.tiny, color = col_dn)
plotshape(trend != trend[1] and not trend ? avg : na, “Down”, shape.circle, location.absolute, size = size.small, color = color.new(col_dn, 50))
// }// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BigBeluga//@version=6
indicator(“Dynamic Flow Ribbons [BigBeluga]”, overlay = true)// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
factor = input.float(3, “Length”, step = 0.01)
col_up = input.color(color.rgb(26, 221, 127), “”, inline = “Col”)
col_dn = input.color(color.rgb(231, 147, 20), “”, inline = “Col”)
// }// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float dist = ta.sma(high-low, 200)trend_line(factor)=>
float src = hlc3
int _direction = na
float trend_line = naupperBand = ta.ema(src, 15) + factor * dist
lowerBand = ta.ema(src, 15) – factor * dist
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])lowerBand := lowerBand > prevLowerBand or src[1] < prevLowerBand ? lowerBand : prevLowerBand upperBand := upperBand < prevUpperBand or src[1] > prevUpperBand ? upperBand : prevUpperBand
prevTrendLine = trend_line[1]
if na(dist[1])
_direction := 1
else if prevTrendLine == prevUpperBand
_direction := src > upperBand ? -1 : 1
else
_direction := src < lowerBand ? 1 : -1 trend_line := _direction == -1 ? lowerBand : upperBand line_ = math.avg(lowerBand, upperBand) [line_, _direction, lowerBand, upperBand] [line_, _direction, lowerBand, upperBand] = trend_line(factor) // } // PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ t_col = _direction == 1 ? col_dn : col_up plot(line_, "TrendLine", color = color.new(t_col, 0), linewidth = 4) plot(line_, "TrendLine", color = color.new(t_col, 80), linewidth = 10) plot(lowerBand+dist, "LowerBand1", color = _direction == -1 ? color.new(t_col, 80) : color.new(t_col, 100), linewidth = 1) plot(lowerBand+dist*0.5, "LowerBand2", color = _direction == -1 ? color.new(t_col, 60) : color.new(t_col, 100), linewidth = 1) plot(lowerBand, "LowerBand3", color = _direction == -1 ? color.new(t_col, 40) : color.new(t_col, 100), linewidth = 1) plot(lowerBand-dist*0.5, "LowerBand4", color = _direction == -1 ? color.new(t_col, 20) : color.new(t_col, 100), linewidth = 1) plot(lowerBand-dist, "LowerBand5", color = _direction == -1 ? color.new(t_col, 0) : color.new(t_col, 100), linewidth = 1) plot(upperBand+dist, "UpperBand5", color = _direction == 1 ? color.new(t_col, 0) : color.new(t_col, 100), linewidth = 1) plot(upperBand+dist*0.5, "UpperBand4", color = _direction == 1 ? color.new(t_col, 20) : color.new(t_col, 100), linewidth = 1) plot(upperBand, "UpperBand3", color = _direction == 1 ? color.new(t_col, 40) : color.new(t_col, 100), linewidth = 1) plot(upperBand-dist*0.5, "UpperBand2", color = _direction == 1 ? color.new(t_col, 60) : color.new(t_col, 100), linewidth = 1) plot(upperBand-dist, "UpperBand1", color = _direction == 1 ? color.new(t_col, 80) : color.new(t_col, 100), linewidth = 1) plotcandle(open, high, low, close, title='CandleStick Coloring', color = color.new(t_col, 50), wickcolor=color.new(t_col, 50), bordercolor = color.new(t_col, 50)) // }07/04/2025 at 7:27 AM #248660Aqui lo tienes:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202//---------------------------------------------////PRC_Deviation Trend Profile [BigBeluga]//version = 0//05.07.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------////---------------------------------------------//// INPUTS - CONFIGURACIÓN DE VARIABLES//---------------------------------------------//// >> Parámetros de la SMA y DesviacionessmaLength = 50 // SMA Lengthmult1 = 1 // Standart Deviation 1mult2 = 2 // Standart Deviation 2mult3 = 3 // Standart Deviation 3// >> Parámetros del Perfil de DistribuciónshowTp = 1 // 1 para mostrar el perfil (Show), 0 para ocultarlobins = 50 // Bins Amount (Cantidad de contenedores)profileOffset = 30 // Offset (Desplazamiento del perfil)// >> Colores del TemacolUpR = 18colUpG = 209colUpB = 235colDnR = 250colDnG = 40colDnB = 86//---------------------------------------------//// VARIABLES PERSISTENTES//---------------------------------------------//ONCE startIndex = -1ONCE trend = 0 // 1 para alcista, -1 para bajista//---------------------------------------------//// CÁLCULOS PRINCIPALES//---------------------------------------------//// --- Media y Volatilidadavg = Average[smaLength](close)atr = AverageTrueRange[200]// --- Niveles de Desviación Estándar (usando ATR)stdv1 = avg + atr * mult1stdv2 = avg + atr * mult2stdv3 = avg + atr * mult3stdv1m = avg - atr * mult1stdv2m = avg - atr * mult2stdv3m = avg - atr * mult3maxDev = stdv3minDev = stdv3m// --- Detección de TendenciaavgDiff = avg - avg[5]IF atr > 0 THENavgCol = avgDiff / atrELSEavgCol = 0ENDIF// --- Lógica de cambio de tendenciaIF avgCol CROSSES OVER 0.1 AND trend <> 1 THENtrend = 1startIndex = barindexENDIFIF avgCol CROSSES UNDER -0.1 AND trend <> -1 THENtrend = -1startIndex = barindexENDIF// --- Color de la media móvil según su momentor = 128g = 128b = 128IF avgDiff > 0 THENr = colUpRg = colUpGb = colUpBELSEr = colDnRg = colDnGb = colDnBENDIF//---------------------------------------------//// LÓGICA DE DIBUJO//---------------------------------------------//// --- Dibuja solo en la última barra para optimizar rendimientoIF IsLastBarUpdate THEN// Dibujar niveles de desviación y etiquetas// Nivel +1DRAWSEGMENT(barindex, stdv1, barindex + 5, stdv1) COLOURED(200,200,200)DRAWTEXT("+1", barindex + 6, stdv1)// Nivel +2DRAWSEGMENT(barindex, stdv2, barindex + 5, stdv2) COLOURED(200,200,200)DRAWTEXT("+2", barindex + 6, stdv2)// Nivel +3DRAWSEGMENT(barindex, stdv3, barindex + 5, stdv3) COLOURED(200,200,200)DRAWTEXT("+3", barindex + 6, stdv3)// Nivel -1DRAWSEGMENT(barindex, stdv1m, barindex + 5, stdv1m) COLOURED(200,200,200)DRAWTEXT("-1", barindex + 6, stdv1m)// Nivel -2DRAWSEGMENT(barindex, stdv2m, barindex + 5, stdv2m) COLOURED(200,200,200)DRAWTEXT("-2", barindex + 6, stdv2m)// Nivel -3DRAWSEGMENT(barindex, stdv3m, barindex + 5, stdv3m) COLOURED(200,200,200)DRAWTEXT("-3", barindex + 6, stdv3m)// Dibujar línea central de la SMADRAWSEGMENT(barindex, avg, barindex + 5, avg) COLOURED(r, g, b) STYLE(Line, 2)// --- Lógica del Perfil de DistribuciónIF showTp = 1 AND startIndex > -1 THEN// Inicializar array de contenedoresUNSET($bin)loockback = barindex - startIndex// Evitar errores si no hay suficientes barrasIF loockback > 0 THEN// Calcular el tamaño de cada contenedorprofileRange = maxDev - minDevstep = profileRange / bins// Llenar los contenedores con cerosFOR k = 0 TO bins - 1 DO$bin[k] = 0NEXT// Contar precios en cada contenedorFOR l = 0 TO loockback - 1 DOc = close[l]mi = minDev[l]s = (maxDev[l] - mi) / binsIF s > 0 THENfor i=0 to bins-1 dolower=mi+s*iupper=lower+sif c>=lower-s and c<=upper+s then$bin[i]=$bin[i]+1endifnextENDIFNEXT// Encontrar el valor máximo en los contenedores para la escala de coloresmaxVal = 0FOR m = 0 TO bins - 1 DOIF $bin[m] > maxVal THENmaxVal = $bin[m]ENDIFNEXT// Dibujar los rectángulos del perfilprofileStart = barindex + profileOffsetFOR j = 0 TO bins - 1 DOval = $bin[j]IF val > 0 THENlower = minDev + step * jupper = lower + step// Dibujar rectánguloDRAWRECTANGLE(profileStart - val, upper, profileStart, lower) COLOURED(r, g, b, 50) BORDERCOLOR(r,g,b,150)ENDIFNEXTENDIFENDIFENDIF// --- Dibujar la SMA y los puntos de cambio de tendencia en todas las barrasIF trend = 1 AND trend[1] <> 1 THENdrawpoint(barindex, avg,3) COLOURED(colUpR, colUpG, colUpB)drawpoint(barindex, avg,5) COLOURED(colUpR, colUpG, colUpB,30)ENDIFIF trend = -1 AND trend[1] <> -1 THENdrawpoint(barindex, avg,3) COLOURED(colDnR, colDnG, colDnB)drawpoint(barindex, avg,5) COLOURED(colDnR, colDnG, colDnB,30)ENDIF//---------------------------------------------//RETURN avg COLOURED(r, g, b) STYLE(Line, 3) AS "SMA Trend"1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on