Projecting where a move is likely to end is one of the most practical uses of Fibonacci analysis. This indicator, adapted to ProBuilder from the “SMC Liquidity Sweep & Fibonacci Extension [MarkitTick]” pinescript, isolates and rebuilds its Fibonacci engine: it detects the most recent A-B-C structure on the chart with an automatic ZigZag and projects the Fibonacci extension levels of the impulse, highlighting the Golden Zone target band.
Instead of dragging the Fibonacci tool by hand, the indicator finds the swing structure for you, freezes it, and plots the projected targets (1.0, 1.272, 1.618) plus a shaded 1.5–1.618 zone where reactions often occur. When price breaks the origin of the structure, the setup is marked as invalidated.
The logic runs in three stages:
ZigZag structure detection. Swing pivots are found with a symmetric lookback (depth bars on each side). A new pivot only becomes a ZigZag point if it moves away from the previous one by more than an adaptive threshold — either an ATR multiple or a fixed percentage of price. The indicator keeps the last three alternating pivots as points A, B and C.
A-B-C validation. A bullish structure is A = low, B = high, C = higher low (with C between A and B). A bearish structure is the mirror: A = high, B = low, C = lower high. Once a valid A-B-C is found it is frozen, so it stays on the chart even as new pivots form, until a new valid structure replaces it or price invalidates it.
Fibonacci projection. From point C, the impulse B − A is projected forward:
Target(ratio) = C + (B − A) × ratio
with ratios 1.0, 1.272 and 1.618 (0.618 optional). The Golden Zone is the band between the 1.5 and 1.618 projections — a common reaction/target area. Elliott-style labels (Wave 3, Harmonic, C/3, Wave 5) annotate each level.
Invalidation. If price closes back beyond point A, the structure is either greyed out or hidden, depending on the setting.
The whole structure is drawn only on the last bar and refreshes cleanly on each update, so the chart never accumulates old drawings.
useATRthr = 0.
//-----------------------------------------------------------//
//PRC_Fibonacci Extension ABC (by MarkitTick)
//version = 0
//06.07.26
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-----------------------------------------------------------//
// Detecta la ultima estructura ABC via ZigZag y proyecta las
// extensiones Fibonacci (1.0 / 1.272 / 1.618) + Golden Zone.
// APLICAR SOBRE EL GRAFICO DE PRECIO (overlay).
//-----------------------------------------------------------//
defparam drawonlastbaronly = true
//-----Inputs (parametros configurables)---------------------//
depth = 5 //Pivot Lookback Depth (barras a cada lado)
useATRthr = 1 //1 = umbral ATR, 0 = umbral % fijo
atrPeriod = 14 //Periodo ATR para el umbral
atrMult = 2.0 //Multiplicador ATR
fixedDevPct = 5.0 //% fijo (solo si useATRthr = 0)
showExt0618 = 0 //Mostrar nivel 0.618
showExt100 = 1 //Mostrar nivel 1.000
showExt1272 = 1 //Mostrar nivel 1.272
showExt1618 = 1 //Mostrar nivel 1.618
extendRight = 1 //1 = extender lineas a la derecha
extBars = 50 //Barras de extension a la derecha
showStructLines = 1 //Dibujar lineas A-B / B-C
showABClabels = 1 //Dibujar etiquetas A B C
showElliott = 1 //Etiquetas Elliott (Wave 3, Harmonic...)
invalidationOn = 1 //Invalidar si el precio rompe el punto A
invalidAction = 0 //0 = grisar estructura, 1 = ocultarla
//-----------------------------------------------------------//
//-----Colores (RGB)-----------------------------------------//
rBull = 0 //#00E676 alcista
gBull = 230
bBull = 118
rBear = 255 //#FF5252 bajista
gBear = 82
bBear = 82
rGray = 100 //invalidada
gGray = 100
bGray = 100
//-----------------------------------------------------------//
//-----Umbral adaptativo-------------------------------------//
atrv = averagetruerange[atrPeriod]
if useATRthr then
zzThr = atrv * atrMult
else
zzThr = close * fixedDevPct / 100
endif
//-----------------------------------------------------------//
//-----Deteccion de pivotes (simetricos, depth por lado)-----//
isPH = 0
isPL = 0
if barindex >= 2 * depth then
okH = 1
okL = 1
for i = 1 to 2 * depth do
if i <> depth then
if high[i] >= high[depth] then
okH = 0
endif
if low[i] <= low[depth] then
okL = 0
endif
endif
next
isPH = okH
isPL = okL
endif
pivBar = barindex - depth
//-----------------------------------------------------------//
//-----Estado ZigZag: ultimos 3 puntos (A, B, C)-------------//
once zzCount = 0
once barA = 0
once priceA = 0
once hiA = 0
once barB = 0
once priceB = 0
once hiB = 0
once barC = 0
once priceC = 0
once hiC = 0
//-----------------------------------------------------------//
//-----Procesar pivote HIGH----------------------------------//
if isPH then
if zzCount = 0 then
barC = pivBar
priceC = high[depth]
hiC = 1
zzCount = 1
elsif hiC = 1 then
if high[depth] > priceC then
barC = pivBar
priceC = high[depth]
endif
else
if abs(high[depth] - priceC) >= zzThr then
barA = barB
priceA = priceB
hiA = hiB
barB = barC
priceB = priceC
hiB = hiC
barC = pivBar
priceC = high[depth]
hiC = 1
if zzCount < 3 then
zzCount = zzCount + 1
endif
endif
endif
endif
//-----------------------------------------------------------//
//-----Procesar pivote LOW-----------------------------------//
if isPL then
if zzCount = 0 then
barC = pivBar
priceC = low[depth]
hiC = 0
zzCount = 1
elsif hiC = 0 then
if low[depth] < priceC then
barC = pivBar
priceC = low[depth]
endif
else
if abs(low[depth] - priceC) >= zzThr then
barA = barB
priceA = priceB
hiA = hiB
barB = barC
priceB = priceC
hiB = hiC
barC = pivBar
priceC = low[depth]
hiC = 0
if zzCount < 3 then
zzCount = zzCount + 1
endif
endif
endif
endif
//-----------------------------------------------------------//
//-----Deteccion de estructura ABC---------------------------//
bullABC = 0
bearABC = 0
if zzCount >= 3 then
if hiA = 0 and hiB = 1 and hiC = 0 then
if priceC > priceA and priceC < priceB then
bullABC = 1
endif
endif
if hiA = 1 and hiB = 0 and hiC = 1 then
if priceC < priceA and priceC > priceB then
bearABC = 1
endif
endif
endif
//-----------------------------------------------------------//
//-----Congelar la ultima estructura valida------------------//
once sExists = 0
once sIsBull = 0
once sInvalid = 0
once sBarA = 0
once sPriceA = 0
once sBarB = 0
once sPriceB = 0
once sBarC = 0
once sPriceC = 0
if bullABC or bearABC then
isNew = 0
if barC <> sBarC or barB <> sBarB or barA <> sBarA then
isNew = 1
endif
if isNew then
sBarA = barA
sPriceA = priceA
sBarB = barB
sPriceB = priceB
sBarC = barC
sPriceC = priceC
sIsBull = bullABC
sExists = 1
sInvalid = 0
endif
endif
//-----------------------------------------------------------//
//-----Invalidacion (el precio rompe el punto A)-------------//
if invalidationOn and sExists = 1 and sInvalid = 0 then
if sIsBull = 1 and close < sPriceA then
sInvalid = 1
endif
if sIsBull = 0 and close > sPriceA then
sInvalid = 1
endif
endif
//-----------------------------------------------------------//
//-----Niveles de extension Fibonacci------------------------//
extDiff = sPriceB - sPriceA
lvl0618 = sPriceC + extDiff * 0.618
lvl100 = sPriceC + extDiff * 1.0
lvl1272 = sPriceC + extDiff * 1.272
lvl1500 = sPriceC + extDiff * 1.5
lvl1618 = sPriceC + extDiff * 1.618
d0618 = round(lvl0618 * 100000) / 100000
d100 = round(lvl100 * 100000) / 100000
d1272 = round(lvl1272 * 100000) / 100000
d1618 = round(lvl1618 * 100000) / 100000
//-----------------------------------------------------------//
//-----Dibujo (solo en la ultima barra)----------------------//
drawIt = 0
if islastbarupdate and sExists = 1 then
if sInvalid = 1 then
if invalidAction = 0 then
rC = rGray
gC = gGray
bC = bGray
drawIt = 1
else
drawIt = 0
endif
else
drawIt = 1
if sIsBull = 1 then
rC = rBull
gC = gBull
bC = bBull
else
rC = rBear
gC = gBear
bC = bBear
endif
endif
if drawIt = 1 then
if extendRight then
endBar = barindex + extBars
else
endBar = barindex
endif
//offset ATR para que el texto no pise la linea/vela
offLvl = atrv * 0.25
if sIsBull = 1 then
offA = 0 - atrv * 0.35
offB = atrv * 0.35
offC = 0 - atrv * 0.35
else
offA = atrv * 0.35
offB = 0 - atrv * 0.35
offC = atrv * 0.35
endif
//--- Lineas de estructura A-B / B-C ---
if showStructLines then
drawsegment(sBarA, sPriceA, sBarB, sPriceB) coloured(rC, gC, bC)
drawsegment(sBarB, sPriceB, sBarC, sPriceC) coloured(rC, gC, bC) style(dottedline)
endif
//--- Etiquetas A B C ---
if showABClabels then
drawtext("A", sBarA, sPriceA + offA) coloured(rC, gC, bC)
drawtext("B", sBarB, sPriceB + offB) coloured(rC, gC, bC)
drawtext("C", sBarC, sPriceC + offC) coloured(rC, gC, bC)
endif
//--- Nivel 0.618 ---
if showExt0618 then
drawsegment(sBarC, lvl0618, endBar, lvl0618) coloured(rC, gC, bC) style(dottedline)
if showElliott then
drawtext("0.618 Wave 5 #d0618#", endBar, lvl0618 + offLvl) coloured(rC, gC, bC)
else
drawtext("0.618 #d0618#", endBar, lvl0618 + offLvl) coloured(rC, gC, bC)
endif
endif
//--- Nivel 1.0 ---
if showExt100 then
drawsegment(sBarC, lvl100, endBar, lvl100) coloured(rC, gC, bC) style(dottedline)
if showElliott then
drawtext("1.0 C/3? #d100#", endBar, lvl100 + offLvl) coloured(rC, gC, bC)
else
drawtext("1.0 #d100#", endBar, lvl100 + offLvl) coloured(rC, gC, bC)
endif
endif
//--- Nivel 1.272 ---
if showExt1272 then
drawsegment(sBarC, lvl1272, endBar, lvl1272) coloured(rC, gC, bC) style(dottedline)
if showElliott then
drawtext("1.272 Harmonic #d1272#", endBar, lvl1272 + offLvl) coloured(rC, gC, bC)
else
drawtext("1.272 #d1272#", endBar, lvl1272 + offLvl) coloured(rC, gC, bC)
endif
endif
//--- Nivel 1.618 ---
if showExt1618 then
drawsegment(sBarC, lvl1618, endBar, lvl1618) coloured(rC, gC, bC)
if showElliott then
drawtext("1.618 Wave 3 #d1618#", endBar, lvl1618 + offLvl) coloured(rC, gC, bC)
else
drawtext("1.618 #d1618#", endBar, lvl1618 + offLvl) coloured(rC, gC, bC)
endif
endif
//--- Golden Zone (banda 1.5 - 1.618) ---
if lvl1618 >= lvl1500 then
gzBot = lvl1500
gzTop = lvl1618
else
gzBot = lvl1618
gzTop = lvl1500
endif
drawrectangle(sBarC, gzBot, endBar, gzTop) coloured(rC, gC, bC) fillcolor(rC, gC, bC, 40)
drawtext("Golden Zone", (sBarC+endBar)*0.5, (gzBot + gzTop) / 2) coloured(rC, gC, bC)
endif
endif
//-----------------------------------------------------------//
return