Indicateur WBR de Flux Charts

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #252468 quote
    bertrandpinoy
    Participant
    Veteran

    bonjour a tous, j ai visionné la video jointe de Flux Charts et j ai commencé le travail pour créer l indicateur compatible chez nous. Mais je ne parviens pas a terminer. Je joins mon travail si un passionné veux aider, cordialement. https://www.youtube.com/watch?v=8XpPaTWhnLA&t=129s

     

    // Wick to Body Ratio Trend Forecast
    // Traduit et adapté pour ProRealTime par Grok (basé sur Flux Charts)
    // Version 1.8.2 – 10:45 AM CEST, 11 Oct 2025 – Correction ligne 137

    // PARAMÈTRES
    maxMatches = 9 // Nombre max de matchs (fixe à 9 pour tester)
    loopbackPeriod = 200 // Réduit pour éviter surcharge
    toleranceRatio = 0.1 // Tolérance pour les matchs de ratio
    forecastLength = 15 // Nombre de bougies futures à prévoir

    // Variables globales
    ratioActuel = 0
    matchRatio0 = 0
    matchRatio1 = 0
    matchRatio2 = 0
    matchRatio3 = 0
    matchRatio4 = 0
    matchRatio5 = 0
    matchRatio6 = 0
    matchRatio7 = 0
    matchRatio8 = 0 // 9 variables
    matchDebut0 = 0
    matchDebut1 = 0
    matchDebut2 = 0
    matchDebut3 = 0
    matchDebut4 = 0
    matchDebut5 = 0
    matchDebut6 = 0
    matchDebut7 = 0
    matchDebut8 = 0 // 9 variables
    nombreMatches = 0
    deviationMouv = 0
    couleurLigne = 0 // 0 pour rouge (faible dev), 1 pour bleu (haute dev)

    // CALCUL DU RATIO WICK-TO-BODY
    bodyCandle = abs(Close – Open)
    totalWick = (High – Low) – bodyCandle
    IF bodyCandle > 0 THEN
    ratioActuel = totalWick / bodyCandle
    ELSE
    ratioActuel = 0 // Éviter division par zéro (doji)
    ENDIF

    // RECHERCHE DE MATCHS HISTORIQUES (sur la dernière barre close)
    IF BarIndex > loopbackPeriod THEN
    nombreMatches = 0
    FOR i = 1 TO loopbackPeriod DO
    IF i < BarIndex THEN
    bodyHist = abs(Close[i] – Open[i])
    totalWickHist = (High[i] – Low[i]) – bodyHist
    IF bodyHist > 0 THEN
    ratioHist = totalWickHist / bodyHist
    tolAdapt = toleranceRatio
    IF nombreMatches < 3 AND toleranceRatio < 0.3 THEN
    tolAdapt = toleranceRatio + 0.05
    ENDIF
    IF abs(ratioHist – ratioActuel) <= tolAdapt AND nombreMatches < maxMatches THEN
    IF nombreMatches = 0 THEN
    matchRatio0 = ratioHist
    ELSE
    IF nombreMatches = 1 THEN
    matchRatio1 = ratioHist
    ELSE
    IF nombreMatches = 2 THEN
    matchRatio2 = ratioHist
    ELSE
    IF nombreMatches = 3 THEN
    matchRatio3 = ratioHist
    ELSE
    IF nombreMatches = 4 THEN
    matchRatio4 = ratioHist
    ELSE
    IF nombreMatches = 5 THEN
    matchRatio5 = ratioHist
    ELSE
    IF nombreMatches = 6 THEN
    matchRatio6 = ratioHist
    ELSE
    IF nombreMatches = 7 THEN
    matchRatio7 = ratioHist
    ELSE
    IF nombreMatches = 8 THEN
    matchRatio8 = ratioHist
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF

    IF nombreMatches = 0 THEN
    matchDebut0 = Close[i]
    ELSE
    IF nombreMatches = 1 THEN
    matchDebut1 = Close[i]
    ELSE
    IF nombreMatches = 2 THEN
    matchDebut2 = Close[i]
    ELSE
    IF nombreMatches = 3 THEN
    matchDebut3 = Close[i]
    ELSE
    IF nombreMatches = 4 THEN
    matchDebut4 = Close[i]
    ELSE
    IF nombreMatches = 5 THEN
    matchDebut5 = Close[i]
    ELSE
    IF nombreMatches = 6 THEN
    matchDebut6 = Close[i]
    ELSE
    IF nombreMatches = 7 THEN
    matchDebut7 = Close[i]
    ELSE
    IF nombreMatches = 8 THEN
    matchDebut8 = Close[i]
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    nombreMatches = nombreMatches + 1
    ENDIF
    ENDIF // Fermeture IF bodyHist > 0
    ENDIF
    NEXT

    // Calcul de la prévision si assez de matchs
    IF nombreMatches >= 3 THEN
    DIM forecastValues(0 TO 14) // Taille fixe à 15 éléments (0 à 14)
    FOR offset = 1 TO forecastLength DO
    sommeMouvs = 0
    FOR j = 0 TO nombreMatches – 1 DO
    IF BarIndex – i – offset > 0 THEN
    IF j = 0 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 1 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 2 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 3 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 4 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 5 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 6 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 7 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ELSE
    IF j = 8 THEN
    mouvement = (Close[i + offset] – Close[i]) / Close[i] * 100
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    sommeMouvs = sommeMouvs + mouvement
    ENDIF
    NEXT
    IF nombreMatches > 0 THEN
    forecastValues[offset-1] = Close + (sommeMouvs / nombreMatches) * Close / 100
    ENDIF
    NEXT

    // Approximation simple de la déviation
    deviationMouv = 0
    FOR j = 0 TO nombreMatches – 1 DO
    IF j = 0 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut0) / matchDebut0 * 100
    ELSE
    IF j = 1 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut1) / matchDebut1 * 100
    ELSE
    IF j = 2 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut2) / matchDebut2 * 100
    ELSE
    IF j = 3 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut3) / matchDebut3 * 100
    ELSE
    IF j = 4 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut4) / matchDebut4 * 100
    ELSE
    IF j = 5 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut5) / matchDebut5 * 100
    ELSE
    IF j = 6 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut6) / matchDebut6 * 100
    ELSE
    IF j = 7 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut7) / matchDebut7 * 100
    ELSE
    IF j = 8 THEN
    mouvement = (Close[BarIndex – 1] – matchDebut8) / matchDebut8 * 100
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    deviationMouv = deviationMouv + abs(mouvement – (sommeMouvs / nombreMatches))
    NEXT
    IF nombreMatches > 0 THEN
    deviationMouv = deviationMouv / nombreMatches
    ENDIF

    // Couleur : faible dev -> rouge, haute -> bleu
    IF deviationMouv < 2 THEN
    couleurLigne = 0 // Rouge
    ELSE
    couleurLigne = 1 // Bleu
    ENDIF

    // TRACÉ DE LA LIGNE DE PRÉVISION
    FOR k = 1 TO forecastLength DO
    IF Time > LastBarTime THEN
    IF couleurLigne = 0 THEN
    DRAWLINE(LastBarIndex + k, forecastValues[k-1], LastBarIndex + forecastLength, forecastValues[forecastLength-1]) COLOURED(RGB(255,0,0)) STYLE(line)
    ELSE
    DRAWLINE(LastBarIndex + k, forecastValues[k-1], LastBarIndex + forecastLength, forecastValues[forecastLength-1]) COLOURED(RGB(0,0,255)) STYLE(line)
    ENDIF
    ENDIF
    NEXT
    ENDIF // Fermeture IF nombreMatches >= 3
    ENDIF // Fermeture IF BarIndex > loopbackPeriod

    // Affichage du ratio actuel
    RETURN ratioActuel AS “WBR Ratio”

    #252592 quote
    Iván González
    Moderator
    Master

    voici:

    //-------------------------------------------//
    //PRC_Wick to Body Ratio Trend Forecast by fluxchart
    //version = 0
    //14.10.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-------------------------------------------//
    // --- ALGORITHM SETTINGS ---
    // Number of candles to look back
    loopback = 400
    // Bar length of the forecast lines
    forecast = 10
    // Ratio Type to use: 1=General, 2=Top Wick, 3=Bottom Wick, 4=Body
    ratioType = 1
    // If 1, only candles of the same direction (bullish/bearish) are compared
    directionBias = 1 // 1=true, 0=false
    // Initial Accuracy: 1=High, 2=Medium, 3=Low
    defaultAccuracy = 2
    
    // --- FORECAST LINES ---
    // High confidence color (R,G,B values)
    deviationHighR = 255
    deviationHighG = 0
    deviationHighB = 0
    // Low confidence color (R,G,B values)
    deviationLowR = 0
    deviationLowG = 0
    deviationLowB = 255
    
    // --- PAST TRENDS ---
    // 1 = Draws a box around matching past trends
    trendSquare = 1
    // 1 = Labels the ratios of matching candles
    trendSquareLabels = 1
    
    // --- OTHER ---
    // 1 = Displays warning messages on the chart
    displayLogs = 1
    
    // --- VARIABLE INITIALIZATION ---
    ONCE accuracy = 0.02
    IF defaultAccuracy = 1 THEN
       accuracy = 0.01
    ELSIF defaultAccuracy = 3 THEN
       accuracy = 0.04
    ENDIF
    
    ONCE ratioNotFindable = 0
    ONCE lastBar = 0
    ONCE matchesFound = 0
    ONCE loopBreaker = 0
    
    // --- CANDLE RATIO CALCULATION ---
    myRatio = 0
    sign = 0
    IF (close - open) > 0 THEN
       sign = 1
    ELSIF (close - open) < 0 THEN
       sign = -1
    ENDIF
    
    // General Ratio
    IF ratioType = 1 THEN
       IF ABS(close - open) > 0 THEN
          myRatio = ((ABS(low - high) - ABS(close - open)) / ABS(close - open)) * sign
       ELSE
          myRatio = 0
       ENDIF
       // Top Wick
    ELSIF ratioType = 2 THEN
       IF ABS(close - open) > 0 THEN
          myRatio = ((MAX(close, open) - high) / ABS(close - open)) * sign
       ELSE
          myRatio = 0
       ENDIF
       // Bottom Wick
    ELSIF ratioType = 3 THEN
       IF ABS(close - open) > 0 THEN
          myRatio = ((MIN(close, open) - low) / ABS(close - open)) * sign
       ELSE
          myRatio = 0
       ENDIF
       // Body Ratio
    ELSIF ratioType = 4 THEN
       IF ABS(high - low) > 0 THEN
          myRatio = (ABS(close - open) / ABS(high - low)) * sign
       ELSE
          myRatio = 0
       ENDIF
    ENDIF
    
    
    // --- MAIN LOGIC (RUNS ON THE LAST BAR) ---
    IF ISLASTBARUPDATE THEN
       
       // Clear arrays for new calculation
       UNSET($sumArray)
       UNSET($sumOfSquaresArray)
       
       // Label for the current candle's ratio
       IF trendSquareLabels = 1 THEN
          
          ratio = ROUND(myRatio[1]*100)/100
          DRAWTEXT("Ratio: #ratio#", barindex[1], high[1] + (high[1]-low[1])*0.5) COLOURED(0,0,255)
       ENDIF
       
       // Loop to adjust accuracy and find matches
       matchesFound = 0
       loopBreaker = 0
       WHILE loopBreaker < 20 DO // Safety loop to prevent infinite loops
          matchesFound = 0
          lastBar = 0
          
          // Reset accumulation arrays
          FOR f = 0 TO forecast - 1 DO
             $sumArray[f] = 0
             $sumOfSquaresArray[f] = 0
          NEXT
          
          // Main loop to search through historical data
          FOR i = forecast + lastBar TO (loopback + forecast) DO
             
             barsDifference = ABS(ABS(myRatio[i]) - ABS(myRatio[1]))
             
             ratioSignI = 0
             IF myRatio[i] > 0 THEN
                ratioSignI = 1
             ELSIF myRatio[i] < 0 THEN
                ratioSignI = -1
             ENDIF
             
             ratioSignCurrent = 0
             IF myRatio[1] > 0 THEN
                ratioSignCurrent = 1
             ELSIF myRatio[1] < 0 THEN
                ratioSignCurrent = -1
             ENDIF
             
             ratioDirectionMatch = (ratioSignI = ratioSignCurrent)
             
             IF (barsDifference <= accuracy AND ratioDirectionMatch) OR (barsDifference <= accuracy AND directionBias = 0) THEN
                matchesFound = matchesFound + 1
                
                // Accumulate values for the forecast
                FOR y = 0 TO forecast - 1 DO
                   candleValue = close[i - y - 1] - close[i]
                   $sumArray[y] = $sumArray[y] + candleValue
                   $sumOfSquaresArray[y] = $sumOfSquaresArray[y] + POW(candleValue, 2)
                NEXT
                
                // Draw boxes and labels on past matches
                IF trendSquare = 1 OR trendSquareLabels = 1 THEN
                   mytop = highest[forecast](high[i-1])
                   mybottom = lowest[forecast](low[i-1])
                   
                   IF trendSquare = 1 THEN
                      DRAWRECTANGLE(barindex[i], mytop, barindex[i - forecast], mybottom) COLOURED(192,192,192)fillcolor(192,192,192,50)
                   ENDIF
                   
                   IF trendSquareLabels = 1 THEN
                      directionColorR = 255
                      directionColorG = 0
                      IF myRatio[i] > 0 THEN
                         directionColorR = 0
                         directionColorG = 255
                      ENDIF
                      ratio = ROUND(myRatio[i]*100)/100
                      DRAWTEXT("Match: #ratio#", barindex[i], high[i] + (high[i]-low[i])*0.5) COLOURED(directionColorR, directionColorG, 0)
                   ENDIF
                ENDIF
                
                // Update to avoid repeating the same candle (optimization)
                lastBar = i
             ENDIF
          NEXT
          
          // Accuracy adjustment logic
          IF matchesFound < 5 THEN
             accuracy = accuracy + 0.01
          ELSIF matchesFound > 15 THEN
             accuracy = accuracy - 0.005
          ELSE
             ratioNotFindable = 0
             BREAK // Exit the WHILE loop
          ENDIF
          
          IF accuracy > 0.1 AND matchesFound = 0 THEN
             ratioNotFindable = 1
             IF displayLogs = 1 THEN
                DRAWTEXT("WARNING: No matches found.", barindex - 50, high) ANCHOR(TOPLEFT, INDEX, YSHIFT) COLOURED(255,165,0)
             ENDIF
             BREAK
          ENDIF
          
          loopBreaker = loopBreaker + 1
       WEND
       
       // --- DRAWING THE FORECAST LINE ---
       IF ratioNotFindable = 0 AND matchesFound > 0 THEN
          deviation = (ArrayMax($sumArray)/matchesFound - ArrayMin($sumArray)/matchesFound) / 2
          
          FOR i = 0 TO forecast - 2 DO
             avgCurrent = $sumArray[i] / matchesFound
             avgNext = $sumArray[i+1] / matchesFound
             
             // Calculate standard deviation for color
             sumSqCurrent = $sumOfSquaresArray[i]
             stdevCurrent = SQRT((sumSqCurrent / matchesFound) - POW(avgCurrent, 2))
             
             // Simulate gradient color
             lineR = deviationLowR
             lineG = deviationLowG
             lineB = deviationLowB
             IF stdevCurrent > deviation / 2 THEN
                lineR = deviationHighR
                lineG = deviationHighG
                lineB = deviationHighB
             ENDIF
             
             // Draw a segment of the forecast line
             DRAWSEGMENT(barindex + i + 1, close[1] + avgCurrent, barindex + i + 2, close[1] + avgNext) STYLE(Line, 2) COLOURED(lineR, lineG, lineB)
          NEXT
       ENDIF
    ENDIF
    
    RETURN
    #252599 quote
    bertrandpinoy
    Participant
    Veteran

    Vous êtes vraiment très fort! merci beaucoup.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Indicateur WBR de Flux Charts


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by bertrandpinoy
3 months, 3 weeks ago.

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