Conversion of Dynamic Flow Ribbons and of Deviation Trend Profile of Tradingview

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #248652 quote
    npam
    Participant
    New

    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
    Cordialement

    Hello,
    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 ?
    Thanks

    Kinds 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 = na

    upperBand = 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)) // }

    TradingViewPRTTranslation.zip
    #248660 quote
    Iván González
    Moderator
    Master

    Aqui lo tienes:

    //---------------------------------------------//
    //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 Desviaciones
    smaLength = 50 // SMA Length
    mult1 = 1 // Standart Deviation 1
    mult2 = 2 // Standart Deviation 2
    mult3 = 3 // Standart Deviation 3
    
    // >> Parámetros del Perfil de Distribución
    showTp = 1 // 1 para mostrar el perfil (Show), 0 para ocultarlo
    bins = 50 // Bins Amount (Cantidad de contenedores)
    profileOffset = 30 // Offset (Desplazamiento del perfil)
    
    // >> Colores del Tema
    colUpR = 18
    colUpG = 209
    colUpB = 235
    
    colDnR = 250
    colDnG = 40
    colDnB = 86
    
    //---------------------------------------------//
    // VARIABLES PERSISTENTES
    //---------------------------------------------//
    ONCE startIndex = -1
    ONCE trend = 0 // 1 para alcista, -1 para bajista
    
    //---------------------------------------------//
    // CÁLCULOS PRINCIPALES
    //---------------------------------------------//
    
    // --- Media y Volatilidad
    avg = Average[smaLength](close)
    atr = AverageTrueRange[200]
    
    // --- Niveles de Desviación Estándar (usando ATR)
    stdv1 = avg + atr * mult1
    stdv2 = avg + atr * mult2
    stdv3 = avg + atr * mult3
    
    stdv1m = avg - atr * mult1
    stdv2m = avg - atr * mult2
    stdv3m = avg - atr * mult3
    
    maxDev = stdv3
    minDev = stdv3m
    
    // --- Detección de Tendencia
    avgDiff = avg - avg[5]
    
    IF atr > 0 THEN
       avgCol = avgDiff / atr
    ELSE
       avgCol = 0
    ENDIF
    
    // --- Lógica de cambio de tendencia
    IF avgCol CROSSES OVER 0.1 AND trend <> 1 THEN
       trend = 1
       startIndex = barindex
    ENDIF
    
    IF avgCol CROSSES UNDER -0.1 AND trend <> -1 THEN
       trend = -1
       startIndex = barindex
    ENDIF
    
    // --- Color de la media móvil según su momento
    r = 128
    g = 128
    b = 128
    
    IF avgDiff > 0 THEN
       r = colUpR
       g = colUpG
       b = colUpB
    ELSE
       r = colDnR
       g = colDnG
       b = colDnB
    ENDIF
    
    //---------------------------------------------//
    // LÓGICA DE DIBUJO
    //---------------------------------------------//
    
    // --- Dibuja solo en la última barra para optimizar rendimiento
    IF IsLastBarUpdate THEN
       
       // Dibujar niveles de desviación y etiquetas
       // Nivel +1
       DRAWSEGMENT(barindex, stdv1, barindex + 5, stdv1) COLOURED(200,200,200)
       DRAWTEXT("+1", barindex + 6, stdv1)
       
       // Nivel +2
       DRAWSEGMENT(barindex, stdv2, barindex + 5, stdv2) COLOURED(200,200,200)
       DRAWTEXT("+2", barindex + 6, stdv2)
       
       // Nivel +3
       DRAWSEGMENT(barindex, stdv3, barindex + 5, stdv3) COLOURED(200,200,200)
       DRAWTEXT("+3", barindex + 6, stdv3)
       
       // Nivel -1
       DRAWSEGMENT(barindex, stdv1m, barindex + 5, stdv1m) COLOURED(200,200,200)
       DRAWTEXT("-1", barindex + 6, stdv1m)
       
       // Nivel -2
       DRAWSEGMENT(barindex, stdv2m, barindex + 5, stdv2m) COLOURED(200,200,200)
       DRAWTEXT("-2", barindex + 6, stdv2m)
       
       // Nivel -3
       DRAWSEGMENT(barindex, stdv3m, barindex + 5, stdv3m) COLOURED(200,200,200)
       DRAWTEXT("-3", barindex + 6, stdv3m)
       
       // Dibujar línea central de la SMA
       DRAWSEGMENT(barindex, avg, barindex + 5, avg) COLOURED(r, g, b) STYLE(Line, 2)
       
       // --- Lógica del Perfil de Distribución
       IF showTp = 1 AND startIndex > -1 THEN
          
          // Inicializar array de contenedores
          UNSET($bin)
          
          loockback = barindex - startIndex
          
          // Evitar errores si no hay suficientes barras
          IF loockback > 0 THEN
             
             // Calcular el tamaño de cada contenedor
             profileRange = maxDev - minDev
             step = profileRange / bins
             
             // Llenar los contenedores con ceros
             FOR k = 0 TO bins - 1 DO
                $bin[k] = 0
             NEXT
             
             // Contar precios en cada contenedor
             FOR l = 0 TO loockback - 1 DO
                c = close[l]
                mi = minDev[l]
                s = (maxDev[l] - mi) / bins
                
                IF s > 0 THEN
                   for i=0 to bins-1 do
                      lower=mi+s*i
                      upper=lower+s
                      if c>=lower-s and c<=upper+s then
                         $bin[i]=$bin[i]+1
                      endif
                   next
                ENDIF
             NEXT
             
             // Encontrar el valor máximo en los contenedores para la escala de colores
             maxVal = 0
             FOR m = 0 TO bins - 1 DO
                IF $bin[m] > maxVal THEN
                   maxVal = $bin[m]
                ENDIF
             NEXT
             
             // Dibujar los rectángulos del perfil
             profileStart = barindex + profileOffset
             
             FOR j = 0 TO bins - 1 DO
                val = $bin[j]
                
                IF val > 0 THEN
                   lower = minDev + step * j
                   upper = lower + step
                   
                   // Dibujar rectángulo
                   DRAWRECTANGLE(profileStart - val, upper, profileStart, lower) COLOURED(r, g, b, 50) BORDERCOLOR(r,g,b,150)
                ENDIF
             NEXT
          ENDIF
       ENDIF
    ENDIF
    
    // --- Dibujar la SMA y los puntos de cambio de tendencia en todas las barras
    IF trend = 1 AND trend[1] <> 1 THEN
       drawpoint(barindex, avg,3) COLOURED(colUpR, colUpG, colUpB)
       drawpoint(barindex, avg,5) COLOURED(colUpR, colUpG, colUpB,30)
    ENDIF
    
    IF trend = -1 AND trend[1] <> -1 THEN
       drawpoint(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"
    
    npam thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Conversion of Dynamic Flow Ribbons and of Deviation Trend Profile of Tradingview


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
npam @npam Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
8 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 07/03/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...