Indicatore fibonacci structure engine

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #259467 quote
    Msport71
    Participant
    Average

    Buongiorno,

    in qualel riga del codice è possibile modificare il lookback dell’indicatore in. modo da vedere gli swing label (HH HL LH LL ) delle precedenti sessioni?


    Grazie

    #259482 quote
    robertogozzi
    Moderator
    Master

    Sostituisci TRUE con FALSE nella riga:

    defparam drawonlastbaronly = true
    
    Iván González and Msport71 thanked this post
    #259484 quote
    Iván González
    Moderator
    Master

    Buongiorno, le etichette degli swing sono limitate alle ultime 10 per impostazione predefinita. Per visualizzare più sessioni storiche, modificare la variabile maxSwLbl = 10. Modificare il 10 con il numero desiderato (ad esempio, 20 o 30). Si trova all’inizio del codice, nella sezione di inizializzazione (riga 68). Tenere presente che un numero molto elevato può rallentare l’indicatore sui timeframe bassi a causa della quantità di testo generato. La prossima volta, per favore, condividi il codice in modo che altri utenti possano aiutarti.

    //----------------------------------------------------------
    // PRC_FIBONACCI STRUCTURE ENGINE
    // Original: WillyAlgoTrader (PineScript v6)
    // version = 1
    // 25.03.2026
    // Iván González @ www.prorealcode.com
    // Sharing ProRealTime knowledge
    //----------------------------------------------------------
    defparam drawonlastbaronly = true
    // ═══════════════════════════════════════
    // SETTINGS
    // ═══════════════════════════════════════
    // ── Main ──
    swingLen = 10       // Swing Detection Length (3-50)
    useATRFilt = 1      // ATR Swing Filter: 1=ON, 0=OFF
    atrMult = 0.5       // ATR Filter Multiplier (0.1-3.0)
    cooldownBars = 5    // Signal Cooldown in bars (1-50)
    // ── Fibonacci Levels (1=Show, 0=Hide) ──
    showFib = 1         // Master toggle Fibonacci
    fibExtBars = 20     // Extension bars to the right (5-100)
    showFib236 = 0      // 0.236 level
    showFib382 = 1      // 0.382 level
    showFib500 = 1      // 0.500 level
    showFib618 = 1      // 0.618 level
    showFib786 = 1      // 0.786 level
    showFibTgt = 1      // Target (-0.618)
    showFibT50 = 1      // -0.5 level
    confTol = 0.3       // Confluence ATR Tolerance (0.05-1.0)
    // ── Structure & Display (1=ON, 0=OFF) ──
    showStruct = 1      // Show BOS / CHoCH
    showSwings = 1      // Show Swing Labels (HH/HL/LH/LL)
    showEngulf = 1      // Show Engulfing Signals
    showSignals = 0     // Show Buy/Sell Signals
    showDash = 1        // Show Dashboard
    // ═══════════════════════════════════════
    // INITIALIZATION
    // ═══════════════════════════════════════
    once swHigh1 = 0
    once swHigh1X = -1
    once swHigh2 = 0
    once swHigh2X = -1
    once swLow1 = 0
    once swLow1X = -1
    once swLow2 = 0
    once swLow2X = -1
    
    once structBias = 0
    once lastBrkHigh = -1
    once lastBrkLow = -1
    
    once fibHigh = 0
    once fibHighX = -1
    once fibLow = 0
    once fibLowX = -1
    once fibHighLive = 0
    once fibLowLive = 0
    
    once barsSinceBuy = 999
    once barsSinceSell = 999
    
    // Buffer counters
    once swLblCnt = 0
    once bosCnt = 0
    once engCnt = 0
    once sigBuyCnt = 0
    once sigSellCnt = 0
    
    maxSwLbl = 10
    maxBos = 5
    maxEng = 5
    maxSig = 3
    
    // ═══════════════════════════════════════
    // CORE CALCULATIONS
    // ═══════════════════════════════════════
    atrLen = 14
    atrVal = averagetruerange[atrLen]
    warmupBars = max(swingLen * 3, 50)
    prdWin = 2 * swingLen + 1
    
    // ═══════════════════════════════════════
    // PIVOT DETECTION (ATR-filtered)
    // ═══════════════════════════════════════
    newSwHigh = 0
    newSwLow = 0
    
    if barindex >= prdWin then
       // ── Pivot High ──
       if high[swingLen] = highest[prdWin](high) then
          ph = high[swingLen]
          phx = barindex - swingLen
          if useATRFilt = 1 then
             minSzH = atrVal * atrMult
          else
             minSzH = 0
          endif
          if swLow1X = -1 then
             passH = 1
          else
             if ph - swLow1 >= minSzH then
                passH = 1
             else
                passH = 0
             endif
          endif
          if passH = 1 then
             swHigh2 = swHigh1
             swHigh2X = swHigh1X
             swHigh1 = ph
             swHigh1X = phx
             newSwHigh = 1
          endif
       endif
       // ── Pivot Low ──
       if low[swingLen] = lowest[prdWin](low) then
          pl = low[swingLen]
          plx = barindex - swingLen
          if useATRFilt = 1 then
             minSzL = atrVal * atrMult
          else
             minSzL = 0
          endif
          if swHigh1X = -1 then
             passL = 1
          else
             if swHigh1 - pl >= minSzL then
                passL = 1
             else
                passL = 0
             endif
          endif
          if passL = 1 then
             swLow2 = swLow1
             swLow2X = swLow1X
             swLow1 = pl
             swLow1X = plx
             newSwLow = 1
          endif
       endif
    endif
    
    // ═══════════════════════════════════════
    // SWING LABEL CLASSIFICATION & BUFFER
    // ═══════════════════════════════════════
    // Swing highs: HH (type=1) or LH (type=3)
    if newSwHigh = 1 and swHigh2X > -1 and barindex >= warmupBars then
       if swHigh1 > swHigh2 then
          swT = 1
       else
          swT = 3
       endif
       if swLblCnt < maxSwLbl then
          $swLblX[swLblCnt] = swHigh1X
          $swLblY[swLblCnt] = swHigh1
          $swLblT[swLblCnt] = swT
          swLblCnt = swLblCnt + 1
       else
          for si = 0 to maxSwLbl - 2 do
             $swLblX[si] = $swLblX[si + 1]
             $swLblY[si] = $swLblY[si + 1]
             $swLblT[si] = $swLblT[si + 1]
          next
          $swLblX[maxSwLbl - 1] = swHigh1X
          $swLblY[maxSwLbl - 1] = swHigh1
          $swLblT[maxSwLbl - 1] = swT
       endif
    endif
    
    // Swing lows: HL (type=2) or LL (type=4)
    if newSwLow = 1 and swLow2X > -1 and barindex >= warmupBars then
       if swLow1 > swLow2 then
          swT = 2
       else
          swT = 4
       endif
       if swLblCnt < maxSwLbl then
          $swLblX[swLblCnt] = swLow1X
          $swLblY[swLblCnt] = swLow1
          $swLblT[swLblCnt] = swT
          swLblCnt = swLblCnt + 1
       else
          for si = 0 to maxSwLbl - 2 do
             $swLblX[si] = $swLblX[si + 1]
             $swLblY[si] = $swLblY[si + 1]
             $swLblT[si] = $swLblT[si + 1]
          next
          $swLblX[maxSwLbl - 1] = swLow1X
          $swLblY[maxSwLbl - 1] = swLow1
          $swLblT[maxSwLbl - 1] = swT
       endif
    endif
    
    // ═══════════════════════════════════════
    // STRUCTURE DETECTION (BOS / CHoCH)
    // ═══════════════════════════════════════
    isBOS = 0
    isCHoCH = 0
    isBullBrk = 0
    isBearBrk = 0
    
    // ── Bullish break: close > swHigh1 ──
    if swHigh1X > -1 and barindex >= warmupBars then
       if close > swHigh1 then
          brkNewH = 0
          if lastBrkHigh = -1 then
             brkNewH = 1
          elsif swHigh1 <> lastBrkHigh then
             brkNewH = 1
          endif
          if brkNewH = 1 then
             if structBias <= 0 then
                isCHoCH = 1
             else
                isBOS = 1
             endif
             structBias = 1
             isBullBrk = 1
             lastBrkHigh = swHigh1
          endif
       endif
    endif
    
    // ── Bearish break: close < swLow1 ──
    if swLow1X > -1 and barindex >= warmupBars then
       if close < swLow1 then
          brkNewL = 0
          if lastBrkLow = -1 then
             brkNewL = 1
          elsif swLow1 <> lastBrkLow then
             brkNewL = 1
          endif
          if brkNewL = 1 then
             if structBias >= 0 then
                isCHoCH = 1
             else
                isBOS = 1
             endif
             structBias = -1
             isBearBrk = 1
             lastBrkLow = swLow1
          endif
       endif
    endif
    
    // ── Store BOS/CHoCH in buffer ──
    if isBOS = 1 or isCHoCH = 1 then
       if isBullBrk = 1 then
          brkPrice = swHigh1
          brkStartX = swHigh1X
       else
          brkPrice = swLow1
          brkStartX = swLow1X
       endif
       brkEndX = barindex
       if isCHoCH = 1 then
          brkType = 2
       else
          brkType = 1
       endif
       if isBullBrk = 1 then
          brkDir = 1
       else
          brkDir = -1
       endif
       if bosCnt < maxBos then
          $bosStartX[bosCnt] = brkStartX
          $bosEndX[bosCnt] = brkEndX
          $bosPrice[bosCnt] = brkPrice
          $bosType[bosCnt] = brkType
          $bosDir[bosCnt] = brkDir
          bosCnt = bosCnt + 1
       else
          for si = 0 to maxBos - 2 do
             $bosStartX[si] = $bosStartX[si + 1]
             $bosEndX[si] = $bosEndX[si + 1]
             $bosPrice[si] = $bosPrice[si + 1]
             $bosType[si] = $bosType[si + 1]
             $bosDir[si] = $bosDir[si + 1]
          next
          $bosStartX[maxBos - 1] = brkStartX
          $bosEndX[maxBos - 1] = brkEndX
          $bosPrice[maxBos - 1] = brkPrice
          $bosType[maxBos - 1] = brkType
          $bosDir[maxBos - 1] = brkDir
       endif
    endif
    
    // ═══════════════════════════════════════
    // FIBONACCI ANCHORS
    // ═══════════════════════════════════════
    // On bullish break: top = current high (live trail), bottom = swLow1 (locked)
    if isBullBrk = 1 then
       fibHigh = high
       fibHighX = barindex
       fibLow = swLow1
       fibLowX = swLow1X
       fibHighLive = 1
       fibLowLive = 0
    endif
    
    // On bearish break: bottom = current low (live trail), top = swHigh1 (locked)
    if isBearBrk = 1 then
       fibLow = low
       fibLowX = barindex
       fibHigh = swHigh1
       fibHighX = swHigh1X
       fibLowLive = 1
       fibHighLive = 0
    endif
    
    // Trail live edge as price extends
    if isBullBrk = 0 and isBearBrk = 0 then
       if fibHighLive = 1 and fibHighX > -1 then
          if high > fibHigh then
             fibHigh = high
             fibHighX = barindex
          endif
       endif
       if fibLowLive = 1 and fibLowX > -1 then
          if low < fibLow then
             fibLow = low
             fibLowX = barindex
          endif
       endif
    endif
    
    // Lock live edge on confirmed pivot (not on break bar)
    if isBullBrk = 0 and isBearBrk = 0 then
       if newSwHigh = 1 and fibHighLive = 1 and swHigh1X > -1 then
          fibHigh = swHigh1
          fibHighX = swHigh1X
          fibHighLive = 0
       endif
       if newSwLow = 1 and fibLowLive = 1 and swLow1X > -1 then
          fibLow = swLow1
          fibLowX = swLow1X
          fibLowLive = 0
       endif
       // Update locked anchors on new confirmed swings
       if newSwHigh = 1 and fibHighLive = 0 and fibHighX > -1 then
          if swHigh1 <> fibHigh then
             fibHigh = swHigh1
             fibHighX = swHigh1X
          endif
       endif
       if newSwLow = 1 and fibLowLive = 0 and fibLowX > -1 then
          if swLow1 <> fibLow then
             fibLow = swLow1
             fibLowX = swLow1X
          endif
       endif
    endif
    
    // ═══════════════════════════════════════
    // FIBONACCI PRICE LEVELS
    // ═══════════════════════════════════════
    fibValid = 0
    fib236 = 0
    fib382 = 0
    fib500 = 0
    fib618 = 0
    fib786 = 0
    fibTgt50 = 0
    fibTgt618 = 0
    
    if fibHighX > -1 and fibLowX > -1 and fibHigh > fibLow then
       fibValid = 1
       fibRng = fibHigh - fibLow
       fib236 = fibHigh - fibRng * 0.236
       fib382 = fibHigh - fibRng * 0.382
       fib500 = fibHigh - fibRng * 0.500
       fib618 = fibHigh - fibRng * 0.618
       fib786 = fibHigh - fibRng * 0.786
       // Extensions: direction depends on structure bias
       if structBias >= 0 then
          // Bullish: targets above fibHigh
          fibTgt50 = fibHigh + fibRng * 0.5
          fibTgt618 = fibHigh + fibRng * 0.618
       else
          // Bearish: targets below fibLow
          fibTgt50 = fibLow - fibRng * 0.5
          fibTgt618 = fibLow - fibRng * 0.618
       endif
    endif
    
    // ═══════════════════════════════════════
    // PREMIUM / DISCOUNT
    // ═══════════════════════════════════════
    inPremium = 0
    inDiscount = 0
    if fibValid = 1 then
       if close > fib500 then
          inPremium = 1
       else
          inDiscount = 1
       endif
    endif
    
    // ═══════════════════════════════════════
    // CONFLUENCE SCORING (weighted)
    // ═══════════════════════════════════════
    if atrVal > 0 then
       confDist = atrVal * confTol
    else
       confDist = 0.001
    endif
    
    confWeight = 0.0
    if fibValid = 1 then
       if showFib236 = 1 and abs(close - fib236) <= confDist then
          confWeight = confWeight + 1.0
       endif
       if abs(close - fib382) <= confDist then
          confWeight = confWeight + 1.5
       endif
       if abs(close - fib500) <= confDist then
          confWeight = confWeight + 2.0
       endif
       if abs(close - fib618) <= confDist then
          confWeight = confWeight + 2.5
       endif
       if abs(close - fib786) <= confDist then
          confWeight = confWeight + 1.5
       endif
    endif
    // Swing level confluence
    if swHigh1X > -1 and abs(close - swHigh1) <= confDist then
       confWeight = confWeight + 1.0
    endif
    if swLow1X > -1 and abs(close - swLow1) <= confDist then
       confWeight = confWeight + 1.0
    endif
    
    confScore = min(confWeight * 10, 100)
    
    // ═══════════════════════════════════════
    // ENGULFING PATTERN DETECTION
    // ═══════════════════════════════════════
    bodySize = max(close, open) - min(close, open)
    bodyAvg = average[14, 1](bodySize)
    
    bearEngulf = 0
    if close < open then
       if bodySize > bodyAvg then
          if close[1] > open[1] then
             if bodySize[1] < bodyAvg[1] then
                if close <= open[1] and open >= close[1] then
                   if close < open[1] or open > close[1] then
                      bearEngulf = 1
                   endif
                endif
             endif
          endif
       endif
    endif
    
    bullEngulf = 0
    if close > open then
       if bodySize > bodyAvg then
          if close[1] < open[1] then
             if bodySize[1] < bodyAvg[1] then
                if close >= open[1] and open <= close[1] then
                   if close > open[1] or open < close[1] then
                      bullEngulf = 1
                   endif
                endif
             endif
          endif
       endif
    endif
    
    // Context filter: premium/discount or confluence
    bearEngCtx = 0
    if bearEngulf = 1 and barindex >= warmupBars then
       if inPremium = 1 or confWeight >= 1.5 then
          bearEngCtx = 1
       endif
    endif
    
    bullEngCtx = 0
    if bullEngulf = 1 and barindex >= warmupBars then
       if inDiscount = 1 or confWeight >= 1.5 then
          bullEngCtx = 1
       endif
    endif
    
    // ── Store engulfing in buffer ──
    if bearEngCtx = 1 then
       if engCnt < maxEng then
          $engX[engCnt] = barindex
          $engY[engCnt] = high
          $engDir[engCnt] = -1
          engCnt = engCnt + 1
       else
          for si = 0 to maxEng - 2 do
             $engX[si] = $engX[si + 1]
             $engY[si] = $engY[si + 1]
             $engDir[si] = $engDir[si + 1]
          next
          $engX[maxEng - 1] = barindex
          $engY[maxEng - 1] = high
          $engDir[maxEng - 1] = -1
       endif
    endif
    
    if bullEngCtx = 1 then
       if engCnt < maxEng then
          $engX[engCnt] = barindex
          $engY[engCnt] = low
          $engDir[engCnt] = 1
          engCnt = engCnt + 1
       else
          for si = 0 to maxEng - 2 do
             $engX[si] = $engX[si + 1]
             $engY[si] = $engY[si + 1]
             $engDir[si] = $engDir[si + 1]
          next
          $engX[maxEng - 1] = barindex
          $engY[maxEng - 1] = low
          $engDir[maxEng - 1] = 1
       endif
    endif
    
    // ═══════════════════════════════════════
    // SIGNAL LOGIC (with cooldown)
    // ═══════════════════════════════════════
    barsSinceBuy = barsSinceBuy + 1
    barsSinceSell = barsSinceSell + 1
    
    buyRaw = 0
    sellRaw = 0
    
    // Buy: bullish engulfing + bias + confluence, OR bullish CHoCH
    if bullEngCtx = 1 and structBias = 1 and confWeight >= 1.5 then
       buyRaw = 1
    endif
    if isCHoCH = 1 and isBullBrk = 1 then
       buyRaw = 1
    endif
    
    // Sell: bearish engulfing + bias + confluence, OR bearish CHoCH
    if bearEngCtx = 1 and structBias = -1 and confWeight >= 1.5 then
       sellRaw = 1
    endif
    if isCHoCH = 1 and isBearBrk = 1 then
       sellRaw = 1
    endif
    
    // Apply cooldown
    confBuy = 0
    confSell = 0
    if buyRaw = 1 and barsSinceBuy >= cooldownBars then
       confBuy = 1
       barsSinceBuy = 0
    endif
    if sellRaw = 1 and barsSinceSell >= cooldownBars then
       confSell = 1
       barsSinceSell = 0
    endif
    
    // ── Store signals in buffer ──
    if confBuy = 1 then
       if sigBuyCnt < maxSig then
          $sigBuyX[sigBuyCnt] = barindex
          $sigBuyY[sigBuyCnt] = low
          sigBuyCnt = sigBuyCnt + 1
       else
          for si = 0 to maxSig - 2 do
             $sigBuyX[si] = $sigBuyX[si + 1]
             $sigBuyY[si] = $sigBuyY[si + 1]
          next
          $sigBuyX[maxSig - 1] = barindex
          $sigBuyY[maxSig - 1] = low
       endif
    endif
    
    if confSell = 1 then
       if sigSellCnt < maxSig then
          $sigSellX[sigSellCnt] = barindex
          $sigSellY[sigSellCnt] = high
          sigSellCnt = sigSellCnt + 1
       else
          for si = 0 to maxSig - 2 do
             $sigSellX[si] = $sigSellX[si + 1]
             $sigSellY[si] = $sigSellY[si + 1]
          next
          $sigSellX[maxSig - 1] = barindex
          $sigSellY[maxSig - 1] = high
       endif
    endif
    
    // ═══════════════════════════════════════════════════
    // DRAWING (all inside islastbarupdate)
    // ═══════════════════════════════════════════════════
    if islastbarupdate then
       atrOff = atrVal * 0.3
       
       // ── SWING LABELS (HH/HL/LH/LL) ──
       if showSwings = 1 and swLblCnt > 0 then
          for i = 0 to swLblCnt - 1 do
             if $swLblT[i] = 1 then
                drawtext("HH", $swLblX[i], $swLblY[i] + atrOff) coloured(0, 230, 118)
             elsif $swLblT[i] = 2 then
                drawtext("HL", $swLblX[i], $swLblY[i] - atrOff) coloured(0, 230, 118)
             elsif $swLblT[i] = 3 then
                drawtext("LH", $swLblX[i], $swLblY[i] + atrOff) coloured(255, 82, 82)
             elsif $swLblT[i] = 4 then
                drawtext("LL", $swLblX[i], $swLblY[i] - atrOff) coloured(255, 82, 82)
             endif
          next
       endif
       
       // ── BOS / CHoCH LINES & LABELS ──
       if showStruct = 1 and bosCnt > 0 then
          for i = 0 to bosCnt - 1 do
             if $bosDir[i] = 1 then
                bR = 0
                bG = 230
                bB = 118
             else
                bR = 255
                bG = 82
                bB = 82
             endif
             drawsegment($bosStartX[i], $bosPrice[i], $bosEndX[i], $bosPrice[i]) coloured(bR, bG, bB) style(dottedline, 2)
             midX = round(($bosStartX[i] + $bosEndX[i]) / 2)
             if $bosDir[i] = 1 then
                lblOff = $bosPrice[i] + atrOff * 0.5
             else
                lblOff = $bosPrice[i] - atrOff * 0.5
             endif
             if $bosType[i] = 2 then
                drawtext("CHoCH", midX, lblOff) coloured(bR, bG, bB)
             else
                drawtext("BOS", midX, lblOff) coloured(bR, bG, bB)
             endif
          next
       endif
       
       // ── FIBONACCI LEVELS ──
       if showFib = 1 and fibValid = 1 then
          rightEdge = barindex + fibExtBars
          
          // Reference line (diagonal from swing low to swing high)
          drawsegment(fibLowX, fibLow, fibHighX, fibHigh) coloured(100, 150, 200) style(dottedline, 1)
          
          // Golden zone box (0.500 – 0.786)
          drawrectangle(barindex, fib500, rightEdge, fib786) coloured(255, 214, 0) fillcolor(255, 214, 0, 30)
          
          // Individual levels
          if showFib236 = 1 then
             drawsegment(barindex, fib236, rightEdge, fib236) coloured(100, 160, 220) style(dottedline, 1)
             drawtext("0.236", rightEdge, fib236) coloured(66, 165, 245)
          endif
          if showFib382 = 1 then
             drawsegment(barindex, fib382, rightEdge, fib382) coloured(80, 150, 220) style(dottedline, 1)
             drawtext("0.382", rightEdge, fib382) coloured(66, 165, 245)
          endif
          if showFib500 = 1 then
             drawsegment(barindex, fib500, rightEdge, fib500) coloured(66, 165, 245) style(dottedline, 2)
             drawtext("0.500", rightEdge, fib500) coloured(66, 165, 245)
          endif
          if showFib618 = 1 then
             drawsegment(barindex, fib618, rightEdge, fib618) coloured(66, 165, 245) style(line, 2)
             drawtext("0.618", rightEdge, fib618) coloured(66, 165, 245)
          endif
          if showFib786 = 1 then
             drawsegment(barindex, fib786, rightEdge, fib786) coloured(80, 150, 220) style(dottedline, 1)
             drawtext("0.786", rightEdge, fib786) coloured(66, 165, 245)
          endif
          
          // Target levels (direction-aware)
          if structBias >= 0 then
             tgtR = 0
             tgtG = 230
             tgtB = 118
             tgtR2 = 0
             tgtG2 = 180
             tgtB2 = 100
          else
             tgtR = 255
             tgtG = 82
             tgtB = 82
             tgtR2 = 200
             tgtG2 = 60
             tgtB2 = 60
          endif
          if showFibTgt = 1 then
             drawsegment(barindex, fibTgt618, rightEdge, fibTgt618) coloured(tgtR, tgtG, tgtB) style(dottedline, 2)
             drawtext("Target", rightEdge, fibTgt618) coloured(tgtR, tgtG, tgtB)
          endif
          if showFibT50 = 1 then
             drawsegment(barindex, fibTgt50, rightEdge, fibTgt50) coloured(tgtR2, tgtG2, tgtB2) style(dottedline, 1)
             drawtext("-0.5", rightEdge, fibTgt50) coloured(tgtR2, tgtG2, tgtB2)
          endif
          
          // Target zone box
          if showFibTgt = 1 or showFibT50 = 1 then
             drawrectangle(barindex, fibTgt50, rightEdge, fibTgt618) coloured(255, 214, 0) fillcolor(255, 214, 0, 30)
          endif
       endif
       
       // ── ENGULFING MARKERS ──
       if showEngulf = 1 and engCnt > 0 then
          for i = 0 to engCnt - 1 do
             if $engDir[i] = 1 then
                drawtext("▲", $engX[i], $engY[i] - atrOff) coloured(0, 230, 118)
             else
                drawtext("▼", $engX[i], $engY[i] + atrOff) coloured(255, 82, 82)
             endif
          next
       endif
       
       // ── BUY / SELL SIGNALS ──
       if showSignals = 1 then
          if sigBuyCnt > 0 then
             for i = 0 to sigBuyCnt - 1 do
                drawtext("BUY", $sigBuyX[i], $sigBuyY[i] - atrOff * 1.5) coloured(0, 230, 118)
             next
          endif
          if sigSellCnt > 0 then
             for i = 0 to sigSellCnt - 1 do
                drawtext("SELL", $sigSellX[i], $sigSellY[i] + atrOff * 1.5) coloured(255, 82, 82)
             next
          endif
       endif
       
       // ── DASHBOARD (simplified panel) ──
       if showDash = 1 then
          // Title
          drawtext("═ FibStructure ═", -200, -10) anchor(topright, xshift, yshift) coloured(200, 200, 200)
          
          // Trend
          if structBias > 0 then
             drawtext("Trend: Bullish", -200, -25) anchor(topright, xshift, yshift) coloured(0, 230, 118)
          elsif structBias < 0 then
             drawtext("Trend: Bearish", -200, -25) anchor(topright, xshift, yshift) coloured(255, 82, 82)
          else
             drawtext("Trend: Neutral", -200, -25) anchor(topright, xshift, yshift) coloured(150, 150, 150)
          endif
          
          // Signal
          if confBuy = 1 then
             drawtext("Signal: BUY", -200, -40) anchor(topright, xshift, yshift) coloured(0, 230, 118)
          elsif confSell = 1 then
             drawtext("Signal: SELL", -200, -40) anchor(topright, xshift, yshift) coloured(255, 82, 82)
          else
             drawtext("Signal: —", -200, -40) anchor(topright, xshift, yshift) coloured(150, 150, 150)
          endif
          
          // Confluence
          if confScore >= 60 then
             drawtext("Conf: Strong #confScore#", -200, -55) anchor(topright, xshift, yshift) coloured(0, 230, 118)
          elsif confScore >= 30 then
             drawtext("Conf: Moderate #confScore#", -200, -55) anchor(topright, xshift, yshift) coloured(255, 214, 0)
          elsif confScore > 0 then
             drawtext("Conf: Weak #confScore#", -200, -55) anchor(topright, xshift, yshift) coloured(200, 180, 80)
          else
             drawtext("Conf: None", -200, -55) anchor(topright, xshift, yshift) coloured(150, 150, 150)
          endif
          
          // Zone
          if inPremium = 1 then
             drawtext("Zone: Premium", -200, -70) anchor(topright, xshift, yshift) coloured(255, 82, 82)
          elsif inDiscount = 1 then
             drawtext("Zone: Discount", -200, -70) anchor(topright, xshift, yshift) coloured(0, 230, 118)
          else
             drawtext("Zone: —", -200, -70) anchor(topright, xshift, yshift) coloured(150, 150, 150)
          endif
          
          // Fib .618 value
          if fibValid = 1 then
             drawtext("Fib .618: #fib618#", -200, -85) anchor(topright, xshift, yshift) coloured(66, 165, 245)
          endif
       endif
    endif
    
    // ═══════════════════════════════════════
    // RETURN — boolean outputs for alerts
    // ═══════════════════════════════════════
    return //confBuy as "Buy Signal", confSell as "Sell Signal", isBOS as "BOS", isCHoCH as "CHoCH"
    



    robertogozzi and Msport71 thanked this post
    #259486 quote
    Iván González
    Moderator
    Master

    Non avevo visto il commento di Roberto 🙂


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

Indicatore fibonacci structure engine


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Msport71 @carlo-pasca Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 03/26/2026
Status: Active
Attachments: No files
Logo Logo
Loading...