Conversion de Lowess Channel

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #252621 quote
    Gigi
    Participant
    Senior

    Bonjour,

    est il possible de convertir cet indicateur? Par avance, merci.

    #252636 quote
    Iván González
    Moderator
    Master

    voici:

    //--------------------------------------------
    //PRC_Lowess Channel + (RSI) by ChartPrime
    //version = 0
    //15.10.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //--------------------------------------------
    // --- Parámetros Configurables ---
    length = 25
    multi = 2.0
    bandwidth = 10
    
    // Colores de la línea central
    colUpR = 0
    colUpG = 255
    colUpB = 0
    
    colDnR = 128
    colDnB = 128
    colDnG = 0
    
    // Color de las bandas
    colBndsR = 61
    colBndsG = 145
    colBndsB = 64
    // --- Fin de Parámetros ---
    
    
    // --- Cálculos del Indicador en un ÚNICO Bucle ---
    
    // Pre-cálculo del ATR
    atr = AverageTrueRange[200]
    
    // Variables de suma compartidas (no dependen de 'y')
    sumWeights = 0.0
    sumWeightedX = 0.0
    sumWeightedX2 = 0.0
    
    // Variables de suma específicas para cada una de las 5 líneas
    sumWeightedYm = 0.0
    sumWeightedXYm = 0.0
    sumWeightedYh1 = 0.0
    sumWeightedXYh1 = 0.0
    sumWeightedYh2 = 0.0
    sumWeightedXYh2 = 0.0
    sumWeightedYl1 = 0.0
    sumWeightedXYl1 = 0.0
    sumWeightedYl2 = 0.0
    sumWeightedXYl2 = 0.0
    
    FOR i = 0 TO length - 1
       x = i
       weight = EXP(-0.5 * (x / bandwidth) * (x / bandwidth))
       
       // Definir el valor 'y' para cada línea
       ym = close[i]
       yh1 = close[i] + (atr[i] * multi)
       yh2 = close[i] + (atr[i] * multi * 2)
       yl1 = close[i] - (atr[i] * multi)
       yl2 = close[i] - (atr[i] * multi * 2)
       
       // Acumular sumas compartidas (solo una vez)
       sumWeights = sumWeights + weight
       sumWeightedX = sumWeightedX + weight * x
       sumWeightedX2 = sumWeightedX2 + weight * x * x
       
       // Acumular sumas específicas para cada línea
       sumWeightedYm = sumWeightedYm + weight * ym
       sumWeightedXYm = sumWeightedXYm + weight * x * ym
       
       sumWeightedYh1 = sumWeightedYh1 + weight * yh1
       sumWeightedXYh1 = sumWeightedXYh1 + weight * x * yh1
       
       sumWeightedYh2 = sumWeightedYh2 + weight * yh2
       sumWeightedXYh2 = sumWeightedXYh2 + weight * x * yh2
       
       sumWeightedYl1 = sumWeightedYl1 + weight * yl1
       sumWeightedXYl1 = sumWeightedXYl1 + weight * x * yl1
       
       sumWeightedYl2 = sumWeightedYl2 + weight * yl2
       sumWeightedXYl2 = sumWeightedXYl2 + weight * x * yl2
    NEXT
    
    // --- Cálculo final para cada línea (post-bucle) ---
    meanX = sumWeightedX / sumWeights
    
    // Línea m
    meanYm = sumWeightedYm / sumWeights
    betam = (sumWeightedXYm - meanX * meanYm * sumWeights) / (sumWeightedX2 - meanX * meanX * sumWeights)
    alpham = meanYm - betam * meanX
    m = alpham + betam * (length / 2)
    
    // Línea h1
    meanYh1 = sumWeightedYh1 / sumWeights
    betah1 = (sumWeightedXYh1 - meanX * meanYh1 * sumWeights) / (sumWeightedX2 - meanX * meanX * sumWeights)
    alphah1 = meanYh1 - betah1 * meanX
    h1 = alphah1 + betah1 * (length / 2)
    
    // Línea h2
    meanYh2 = sumWeightedYh2 / sumWeights
    betah2 = (sumWeightedXYh2 - meanX * meanYh2 * sumWeights) / (sumWeightedX2 - meanX * meanX * sumWeights)
    alphah2 = meanYh2 - betah2 * meanX
    h2 = alphah2 + betah2 * (length / 2)
    
    // Línea l1
    meanYl1 = sumWeightedYl1 / sumWeights
    betal1 = (sumWeightedXYl1 - meanX * meanYl1 * sumWeights) / (sumWeightedX2 - meanX * meanX * sumWeights)
    alphal1 = meanYl1 - betal1 * meanX
    l1 = alphal1 + betal1 * (length / 2)
    
    // Línea l2
    meanYl2 = sumWeightedYl2 / sumWeights
    betal2 = (sumWeightedXYl2 - meanX * meanYl2 * sumWeights) / (sumWeightedX2 - meanX * meanX * sumWeights)
    alphal2 = meanYl2 - betal2 * meanX
    l2 = alphal2 + betal2 * (length / 2)
    
    // --- Lógica de Color para la línea central ---
    IF m > m[3] THEN
       colorR = colUpR
       colorG = colUpG
       colorB = colUpB
    ELSIF m < m[3] THEN
       colorR = colDnR
       colorG = colDnG
       colorB = colDnB
    ENDIF
    
    // --- Dibujado de las líneas ---
    RETURN h2 COLOURED(colBndsR, colBndsG, colBndsB) STYLE(dottedline) AS "Higher Band 2", h1 COLOURED(colBndsR, colBndsG, colBndsB) STYLE(dottedline) AS "Higher Band 1", m COLOURED(colorR, colorG, colorB) STYLE(line, 2) AS "Middle", l1 COLOURED(colBndsR, colBndsG, colBndsB) STYLE(dottedline) AS "Lower Band 1", l2 COLOURED(colBndsR, colBndsG, colBndsB) STYLE(dottedline) AS "Lower Band 2"
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Conversion de Lowess Channel


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Gigi @gigi Participant
Summary

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

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