IMBALANCE projections rectangulaires

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #266087 quote
    Bernard13Bernard13
    Participant
    Veteran

    Bonjour @JC_Bywan

    Cette capture te sera peut-être utile: XAUUSD en 5m Bougie de 13h00.

    Cordialement.

    JC_Bywan thanked this post
    Retracement-Capture-decran-2026-11-06-135959.png Retracement-Capture-decran-2026-11-06-135959.png
    #266093 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    Ok merci, voici via xauusd la version modifiée permettant de tenir compte de la mèche la plus extrême d’une série de bougies en retracement partiel. A tester.


    //----------------------------------------------
    // IMBALANCES VIERGES v4 — projection 30 jours
    // Detection originale conservee
    // + prolongation des zones non retracees
    //----------------------------------------------
    DEFPARAM DrawOnLastBarOnly = false
    DEFPARAM calculateonlastbars = 20000
    
    // ================================================================
    // PARAMETRES
    // ================================================================
    imbMax = 200
    days30 = 8640
    
    // ================================================================
    // INITIALISATION
    // ================================================================
    ONCE topIdx = 0
    ONCE topCount = 0
    ONCE botIdx = 0
    ONCE botCount = 0
    
    // ================================================================
    // DETECTION ORIGINALE — inchangee
    // ================================================================
    TopImb = 0
    TopImbalance = low[2] <= open[1] AND high[0] >= close[1]
    TopImbalancesize = low[2] - high[0]
    IF TopImbalance AND TopImbalancesize > 0 THEN
    LowerWick = (min(open,close) - low) <= (range * 0.05)
    Body = abs(Close - Open)
    TopImb = (TopImbalancesize > Body) AND LowerWick AND (low[2] <= (min(open,close) + 2*PipSize))
    DrawCandle(low[2], low[2], high[0], high[0]) coloured(255,255,0)
    ENDIF
    
    BottomInbalance  = high[2] >= open[1] AND low[0] <= close[1]
    BottomInbalancesize = low[0] - high[2]
    IF BottomInbalance AND BottomInbalancesize > 0 THEN
    DrawCandle(low[0], low[0], high[2], high[2]) coloured(255,255,0)
    ENDIF
    
    // ================================================================
    // STOCKAGE DES ZONES DETESTEES
    // ================================================================
    IF TopImbalance AND TopImbalancesize > 0 THEN
    sl = topIdx MOD imbMax
    $tH[sl] = low[2]
    $tL[sl] = high[0]
    $tL2[sl] = $tL[sl]//// JC/Ajouté
    $tB[sl] = barindex
    $tF[sl] = 0
    topIdx = topIdx + 1
    IF topCount < imbMax THEN
    topCount = topCount + 1
    ENDIF
    ENDIF
    
    IF BottomInbalance AND BottomInbalancesize > 0 THEN
    sl = botIdx MOD imbMax
    $bH[sl] = low[0]
    $bL[sl] = high[2]
    $bH2[sl] = $bH[sl]//// JC/Ajouté
    $bB[sl] = barindex
    $bF[sl] = 0
    botIdx = botIdx + 1
    IF botCount < imbMax THEN
    botCount = botCount + 1
    ENDIF
    ENDIF
    
    // ================================================================
    // DETECTION RETRACEMENT — zone touchee = zone remplie
    // ================================================================
    IF topCount > 0 THEN
    FOR i = 0 TO topCount - 1 DO
    sl = (topIdx - topCount + i) MOD imbMax
    IF $tF[sl]<1 AND barindex > $tB[sl] THEN//IF $tF[sl] = 0 AND barindex > $tB[sl] THEN
    //IF high >= $tL[sl] AND low <= $tH[sl] THEN
    //$tF[sl] = 1
    //ENDIF
    ////   JC/remplacé par:
    IF high >= $tH[sl] THEN
    $tF[sl] = 1
    elsif high >= max($tL[sl],$tL2[sl]) THEN
    $tF[sl] = 0.5
    $tL2[sl] = high
    ENDIF
    ////   JC/fin de remplacement
    ENDIF
    NEXT
    ENDIF
    
    IF botCount > 0 THEN
    FOR i = 0 TO botCount - 1 DO
    sl = (botIdx - botCount + i) MOD imbMax
    IF $bF[sl]<1 AND barindex > $bB[sl] THEN//IF $bF[sl] = 0 AND barindex > $bB[sl] THEN
    //IF high >= $bL[sl] AND low <= $bH[sl] THEN
    //$bF[sl] = 1
    //ENDIF
    ////   JC/remplacé par:
    IF low <= $bL[sl] THEN
    $bF[sl] = 1
    elsif low <= min($bH[sl],$bH2[sl]) THEN
    $bF[sl] = 0.5
    $bH2[sl] = low
    ENDIF
    ////   JC/fin de remplacement
    ENDIF
    NEXT
    ENDIF
    
    // ================================================================
    // PROJECTION — zones vierges prolongees jusqu a maintenant
    // ================================================================
    IF islastbarupdate THEN
    
    barLimit = barindex - days30
    
    // Top imbalances vierges (orange)
    IF topCount > 0 THEN
    FOR i = 0 TO topCount - 1 DO
    sl = (topIdx - topCount + i) MOD imbMax
    //IF $tF[sl] = 0 AND $tB[sl] >= barLimit THEN
    //DrawRectangle($tB[sl], $tH[sl], barindex, $tL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
    //ENDIF
    ////   JC/remplacé par:
    IF $tF[sl]<1 AND $tB[sl] >= barLimit THEN
    if $tF[sl]=0 then// zones non retracées
    DrawRectangle($tB[sl], $tH[sl], barindex, $tL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
    elsif $tF[sl]=0.5 then// zones partiellement retracées
    DrawRectangle($tB[sl], $tH[sl], barindex, $tL2[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
    endif
    ENDIF
    ////   JC/fin de remplacement
    NEXT
    ENDIF
    
    // Bottom imbalances vierges (jaune clair)
    IF botCount > 0 THEN
    FOR i = 0 TO botCount - 1 DO
    sl = (botIdx - botCount + i) MOD imbMax
    //IF $bF[sl] = 0 AND $bB[sl] >= barLimit THEN
    //DrawRectangle($bB[sl], $bH[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
    //ENDIF
    ////   JC/remplacé par:
    IF $bF[sl]<1 AND $bB[sl] >= barLimit THEN
    if $bF[sl]=0 then// zones non retracées
    DrawRectangle($bB[sl], $bH[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
    elsif $bF[sl]=0.5 then// zones partiellement retracées
    DrawRectangle($bB[sl], $bH2[sl], barindex, $bL[sl]) coloured(255,200,0,20) BorderColor(255,200,0,160)
    endif
    ENDIF
    ////   JC/fin de remplacement
    NEXT
    ENDIF
    
    ENDIF
    
    RETURN
    




    Iván González and Bernard13 thanked this post
    Capture-decran-2026-11-06.png Capture-decran-2026-11-06.png
    #266095 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Espérons que nous trouverons une solution cette fois-ci. Voici une autre suggestion :

    //----------------------------------------------
    // VIRGIN IMBALANCES v6
    //----------------------------------------------
    DEFPARAM DrawOnLastBarOnly = true
    DEFPARAM CalculateOnLastBars = 20000
    
    // ================================================================
    // SETTINGS
    // ================================================================
    // projection window in bars: 720 = 30 days in H1 (8640 = 30 days in 5 min)
    maxBars = 720
    
    // ================================================================
    // INITIALISATION
    // ================================================================
    ONCE nTop = 0
    ONCE nBot = 0
    ONCE tFirst = 0
    ONCE bFirst = 0
    
    // ================================================================
    // ORIGINAL DETECTION - unchanged
    // ================================================================
    TopImb = 0
    TopImbalance = low[2] <= open[1] AND high[0] >= close[1]
    TopImbalancesize = low[2] - high[0]
    IF TopImbalance AND TopImbalancesize > 0 THEN
       LowerWick = (min(open,close) - low) <= (range * 0.05)
       Body = abs(Close - Open)
       TopImb = (TopImbalancesize > Body) AND LowerWick AND (low[2] <= (min(open,close) + 2*PipSize))
    ENDIF
    
    BottomInbalance = high[2] >= open[1] AND low[0] <= close[1]
    BottomInbalancesize = low[0] - high[2]
    
    // ================================================================
    // STORE THE NEW ZONES
    // Top imbalance: the gap is ABOVE price, between high[0] and low[2]
    // Bottom imbalance: the gap is BELOW price, between high[2] and low[0]
    // ================================================================
    IF TopImbalance AND TopImbalancesize > 0 THEN
       $tH[nTop] = low[2]      // upper edge, fixed
       $tL0[nTop] = high[0]    // original lower edge
       $tL[nTop] = high[0]     // lower edge of the unfilled part: moves UP
       $tB[nTop] = barindex
       nTop = nTop + 1
    ENDIF
    
    IF BottomInbalance AND BottomInbalancesize > 0 THEN
       $bL[nBot] = high[2]     // lower edge, fixed
       $bH0[nBot] = low[0]     // original upper edge
       $bH[nBot] = low[0]      // upper edge of the unfilled part: moves DOWN
       $bB[nBot] = barindex
       nBot = nBot + 1
    ENDIF
    
    // ================================================================
    // RETRACEMENT - each candle eats the part of the zone it touches
    // The zone is only cut, never enlarged: a candle that comes back less
    // deep than an earlier one changes nothing. And the high (low) of the
    // candle in progress can only rise (fall), so recalculating it on every
    // tick always leaves the same edge as the close of the candle.
    // ================================================================
    barLimit = barindex - maxBars
    
    // Top zones: the high of the candle pushes the lower edge up
    IF nTop > tFirst THEN
       newFirst = tFirst
       FOR k = tFirst TO nTop - 1 DO
          IF $tB[k] < barLimit THEN
             // older than the window: no longer followed nor drawn
             newFirst = k + 1
          ELSIF barindex > $tB[k] THEN
             IF high > $tL[k] THEN
                IF $tL[k] = $tL0[k] THEN
                   // first candle that comes back into the zone
                   $tT[k] = barindex
                ENDIF
                $tL[k] = min(high, $tH[k])
             ENDIF
          ENDIF
       NEXT
       tFirst = newFirst
    ENDIF
    
    // Bottom zones: the low of the candle pushes the upper edge down
    IF nBot > bFirst THEN
       newFirst = bFirst
       FOR k = bFirst TO nBot - 1 DO
          IF $bB[k] < barLimit THEN
             newFirst = k + 1
          ELSIF barindex > $bB[k] THEN
             IF low < $bH[k] THEN
                IF $bH[k] = $bH0[k] THEN
                   $bT[k] = barindex
                ENDIF
                $bH[k] = max(low, $bL[k])
             ENDIF
          ENDIF
       NEXT
       bFirst = newFirst
    ENDIF
    
    // ================================================================
    // DRAWING - everything is redrawn from the arrays on the last bar,
    // so the rectangles of the previous bars do not pile up.
    // A partially filled zone is rebuilt step by step from the candles:
    // a new rectangle starts at each candle that goes deeper into it.
    // ================================================================
    IF islastbarupdate THEN
       
       // Top imbalances
       IF nTop > tFirst THEN
          FOR k = tFirst TO nTop - 1 DO
             // original imbalance on its 3 candles (yellow)
             DrawRectangle($tB[k] - 2, $tH[k], $tB[k], $tL0[k]) coloured(255,255,0,120) BorderColor(255,255,0,0)
             // unfilled part projected up to the current candle
             IF $tL[k] < $tH[k] THEN
                xStart = $tB[k]
                edge = $tL0[k]
                IF $tL[k] > $tL0[k] THEN
                   FOR j = $tT[k] TO barindex DO
                      hj = high[barindex - j]
                      IF hj > edge THEN
                         DrawRectangle(xStart, $tH[k], j, edge) coloured(255,200,0,20) BorderColor(255,200,0,160)
                         xStart = j
                         edge = hj
                      ENDIF
                   NEXT
                ENDIF
                DrawRectangle(xStart, $tH[k], barindex, edge) coloured(255,200,0,20) BorderColor(255,200,0,160)
             ENDIF
          NEXT
       ENDIF
       
       // Bottom imbalances
       IF nBot > bFirst THEN
          FOR k = bFirst TO nBot - 1 DO
             DrawRectangle($bB[k] - 2, $bH0[k], $bB[k], $bL[k]) coloured(255,255,0,120) BorderColor(255,255,0,0)
             IF $bH[k] > $bL[k] THEN
                xStart = $bB[k]
                edge = $bH0[k]
                IF $bH[k] < $bH0[k] THEN
                   FOR j = $bT[k] TO barindex DO
                      lj = low[barindex - j]
                      IF lj < edge THEN
                         DrawRectangle(xStart, edge, j, $bL[k]) coloured(255,200,0,20) BorderColor(255,200,0,160)
                         xStart = j
                         edge = lj
                      ENDIF
                   NEXT
                ENDIF
                DrawRectangle(xStart, edge, barindex, $bL[k]) coloured(255,200,0,20) BorderColor(255,200,0,160)
             ENDIF
          NEXT
       ENDIF
       
    ENDIF
    
    RETURN
    



    JC_Bywan and Bernard13 thanked this post
    image-1793981044258.png image-1793981044258.png
    #266097 quote
    bertrandpinoybertrandpinoy
    Participant
    Veteran

    Ca progresse, bel esprit collectif c est cool.

    Bernard13 thanked this post
Viewing 4 posts - 16 through 19 (of 19 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

IMBALANCE projections rectangulaires


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 18 replies,
has 6 voices, and was last updated by bertrandpinoybertrandpinoy
2 days, 21 hours ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 10/07/2023
Status: Active
Attachments: 10 files
ProRealCode ProRealCode
Loading...