CONVERSION INDICADOR TRADINGVIEW:Regression Indicator

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #237045 quote
    Fr7Fr7
    Participant
    Master

    Solicito, si es posible, convertir el indicador adjunto:

    Descripción general del indicador:
    El indicador de regresión está diseñado para ayudar a los operadores a identificar tendencias y posibles reversiones en los movimientos de precios. Al calcular una línea de regresión y un indicador de regresión normalizado, proporciona señales visuales claras para la dirección del mercado, lo que ayuda a tomar decisiones comerciales informadas. El indicador se actualiza dinámicamente con los últimos datos del mercado, lo que garantiza señales oportunas y relevantes.

    https://es.tradingview.com/script/rFrilcDi-Regression-Indicator-BigBeluga/
    A ver si Iván el moderador tiene un hueco libre y lo puede traducir.
    Muchas gracias.

    #237046 quote
    Fr7Fr7
    Participant
    Master

    // 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=5
    indicator(“Regression Indicator [BigBeluga]”, overlay = false, max_bars_back = 500)

    // =====================================================================================================================}
    // INPUTS
    // ====================================================================================================================={

    int length = input.int(400, “Regression Length”)
    int length1 = input.int(100, “Regression Normalization”)
    int length2 = input.int(50, “Signal Line”)

    color m_color = #049ef7

    // =====================================================================================================================}
    // CALCULATIONS
    // ====================================================================================================================={

    // @function regression_indicator is a Normalized Ratio of Regression Lines with close
    regression_indicator(src, length) =>
    sum_x = 0.0
    sum_y = 0.0
    sum_xy = 0.0
    sum_x_sq = 0.0
    distance = 0.0
    // Calculate Sum
    for i = 0 to length – 1 by 1
    sum_x += i + 1
    sum_y += src[i]
    sum_xy += (i + 1) * src[i]
    sum_x_sq += math.pow(i + 1, 2)

    // Calculate linear regression coefficients
    slope = (length * sum_xy – sum_x * sum_y)
    / (length * sum_x_sq – math.pow(sum_x, 2))
    intercept = (sum_y – slope * sum_x) / length

    // Calculate Regression Indicator
    y1 = intercept + slope
    distance := (close – y1)
    distance_n = ta.sma((distance – ta.sma(distance, length1))
    / ta.stdev(distance, length1), 10)

    [distance_n, y1]

    [y, y1] = regression_indicator(close, length)

    // Signal Lines
    mean = ta.sma(y, length2)
    mean1 = ta.ema(y, 5)
    // Conditions
    cond1 = ta.crossunder(mean1, mean) and y > 0
    cond2 = ta.crossover(mean1, mean) and y < 0
    cond3 = ta.crossover(y, 0)
    cond4 = ta.crossunder(y, 0)

    // =====================================================================================================================}
    // PLOT
    // ====================================================================================================================={
    // Candles Colors
    color = y > 0 ? color.from_gradient(y, 0, 1, na, m_color) : color.from_gradient(y, -1, 0, chart.fg_color, na)

    barcolor(color)
    plotcandle(open, high, low, close, “Color Candles”,
    color = color,
    wickcolor = color,
    bordercolor = color,
    force_overlay = true
    )

    // Plot Regression Line
    plot(series = y1,
    title = “Regression Line”,
    color = color,
    linewidth = 2,
    force_overlay = true
    )
    // Plot Regression Indicator
    p1 = plot(series = y,
    title = “Regression Indicator”,
    color = color,
    linewidth = 1
    )

    p0 = plot(series = 0,
    title = “Zero Line”,
    color = color,
    linewidth = 1
    )

    // Fill Color Regression Indicator
    fill(p1, p0, 2.5, 0, m_color, na, title = “Upper Fill”)
    fill(p1, p0, 0, -2.5, na, chart.fg_color, title = “Lower Fill”)

    // Signal Line
    plot(mean, color = color.rgb(3, 100, 165, 52), linewidth = 2)

    // Arrow Trend Direction
    var txt = “”
    switch
    cond3 => txt := “➚”
    cond4 => txt := “➘”

    if barstate.islast
    label.delete(
    label.new(
    x = bar_index+3,
    y = y1,
    text = txt,
    style = label.style_label_center,
    color = color(na),
    textcolor = color,
    size = size.huge,
    force_overlay = true
    )[1]
    )

    // Reversion Signals
    if cond1
    label.new(
    x = bar_index,
    y = high,
    text = “◓”,
    style = label.style_label_down,
    color = color(na),
    textcolor = chart.fg_color,
    size = size.large,
    force_overlay = true
    )

    if cond2
    label.new(
    x = bar_index,
    y = low,
    text = “◒”,
    style = label.style_label_up,
    color = color(na),
    textcolor = m_color,
    size = size.large,
    force_overlay = true
    )

    // Trend Signals
    plotchar(cond3 ? 0 : na, “TrendUp”, “⦿”,
    location = location.absolute,
    size = size.small,
    color = #0364a5
    )
    plotchar(cond3 ? close : na, “TrendUp”, “⦿”,
    location = location.absolute,
    size = size.small,
    color = #0364a5,
    force_overlay = true
    )

    plotchar(cond4 ? 0 : na, “TrendDn”, “⦿”,
    location = location.absolute,
    size = size.small,
    color = chart.fg_color
    )
    plotchar(cond4 ? close : na, “TrendDn”, “⦿”,
    location = location.absolute,
    size = size.small,
    color = chart.fg_color,
    force_overlay = true
    )

    // =====================================================================================================================}

    #237117 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Buenas! Aquí tienes la traducción

    //-------------------------------------------------------//
    //PRC_Regression Oscilator
    //version = 0
    //05.09.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-------------------------------------------------------//
    //-----Inputs--------------------------------------------//
    //-------------------------------------------------------//
    length=400 //regression Length
    length1=100 //regression normalization
    length2=50 //signal lane
    //-------------------------------------------------------//
    //-----Regression Calculation----------------------------//
    //-------------------------------------------------------//
    src=close
    sumx=0
    sumy=0
    sumxy=0
    sumxsq=0
    distance=0
    //Calculate sum
    for i=0 to length-1 do
    sumx=sumx+i+1
    sumy=sumy+src[i]
    sumxy=sumxy+(i+1)*src[i]
    sumxsq=sumxsq+pow(i+1,2)
    next
    //Calculate linear regression coefficients
    slope=(length*sumxy-sumx*sumy)/(length*sumxsq-pow(sumx,2))
    intercept=(sumy-slope*sumx)/length
    //Calculate Regression indicator
    y1=intercept+slope
    distance=(close-y1)
    distanceN=average[10]((distance-average[length1](distance))/std[length1](distance))
    //-------------------------------------------------------//
    //-----Signal Lines--------------------------------------//
    //-------------------------------------------------------//
    y=distanceN
    mean=average[length2](y)
    mean1=average[5](y)
    //-------------------------------------------------------//
    //-----Conditions----------------------------------------//
    //-------------------------------------------------------//
    cond1=mean1 crosses under mean and y>0
    cond2=mean1 crosses over mean and y<0
    cond3=y crosses over 0
    cond4=y crosses under 0
    //-------------------------------------------------------//
    //-----Plot----------------------------------------------//
    //-------------------------------------------------------//
    if y>0 then
    r=0
    g=255
    b=255
    else
    r=255
    g=0
    b=255
    endif
    //Reversion Signals
    if cond1 then
    drawtext("▼",barindex,mean)coloured("fuchsia")
    elsif cond2 then
    drawtext("▲",barindex,mean)coloured(0,255,255)
    endif
    //Trend Signals
    if cond3 then
    drawpoint(barindex,0,3)coloured("lightgreen")
    elsif cond4 then
    drawpoint(barindex,0,3)coloured("red")
    endif
    //-------------------------------------------------------//
    return y as "Regression Line" coloured(r,g,b)style(line,3), 0 as "Zero" style(dottedline), mean as "mean"coloured(3,100,165)style(line,2)
    Fr7 thanked this post
    #237118 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Y este sería el mismo indicador pero en precio

    //-------------------------------------------------------//
    //PRC_Regression Oscilator on Price
    //version = 0
    //05.09.2024
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-------------------------------------------------------//
    //-----Inputs--------------------------------------------//
    //-------------------------------------------------------//
    length=400 //regression Length
    length1=100 //regression normalization
    length2=50 //signal lane
    colorcandle=1
    trendsignal=1
    revsignal=1
    //-------------------------------------------------------//
    //-----Regression Calculation----------------------------//
    //-------------------------------------------------------//
    src=close
    sumx=0
    sumy=0
    sumxy=0
    sumxsq=0
    distance=0
    //Calculate sum
    for i=0 to length-1 do
    sumx=sumx+i+1
    sumy=sumy+src[i]
    sumxy=sumxy+(i+1)*src[i]
    sumxsq=sumxsq+pow(i+1,2)
    next
    //Calculate linear regression coefficients
    slope=(length*sumxy-sumx*sumy)/(length*sumxsq-pow(sumx,2))
    intercept=(sumy-slope*sumx)/length
    //Calculate Regression indicator
    y1=intercept+slope
    distance=(close-y1)
    distanceN=average[10]((distance-average[length1](distance))/std[length1](distance))
    //-------------------------------------------------------//
    //-----Signal Lines--------------------------------------//
    //-------------------------------------------------------//
    y=distanceN
    mean=average[length2](y)
    mean1=average[5](y)
    //-------------------------------------------------------//
    //-----Conditions----------------------------------------//
    //-------------------------------------------------------//
    cond1=mean1 crosses under mean and y>0
    cond2=mean1 crosses over mean and y<0
    cond3=y crosses over 0
    cond4=y crosses under 0
    //-------------------------------------------------------//
    //-----Plot----------------------------------------------//
    //-------------------------------------------------------//
    if y>0 then
    r=0
    g=255
    b=255
    else
    r=255
    g=0
    b=255
    endif
    //Reversion Signals
    if revsignal and cond1 then
    drawtext("▼",barindex,high+0.25*tr)coloured("fuchsia")
    elsif revsignal and cond2 then
    drawtext("▲",barindex,low-0.25*tr)coloured(0,255,255)
    endif
    //Trend Signals
    if trendsignal and cond3 then
    drawpoint(barindex,close,3)coloured("lightgreen")
    elsif trendsignal and cond4 then
    drawpoint(barindex,close,3)coloured("red")
    endif
    //Draw candles
    if colorcandle then
    drawcandle(open,high,low,close)coloured(r,g,b,150)
    endif
    //-------------------------------------------------------//
    return y1 as "Regression Line" coloured(r,g,b)style(line,3)
    
    Fr7 thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

CONVERSION INDICADOR TRADINGVIEW:Regression Indicator


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
Fr7 @fr7 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Iván GonzálezIván González
2 years ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 09/03/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...