ProRealCode - Trading & Coding with ProRealTime™
Buenas días, no sé si es posible el screener que me gustaría tener; en primer lugar explico que es lo que busco: por mi forma de ver el trading me interesa todo lo relacionado con ondas de Elliot, patrones chartistas…, por eso viendo lo que Prorealtime tiene disponible, con la multitud de indicadores que generosamente publicáis todas las semanas, me gustó mucho el que Iván subió hace pocas semanas “Fibonacci Structure Engine”, que busco en él?, la zona dorada, cuando tras un CHoCH o un BOS el precio retrocede en busca de niveles de fibonacci 0,50/0,61/0,78… , qué es lo complicado aquí, mirar decenas de gráficos a ver cual respeta dichos niveles y rebota o retrocede, por eso viendo durante un tiempo me he dado cuenta que en muchas ocasiones cuando el precio hace lo que busco, veo que en intradía indicadores como el “Wick Pressure Zones” o el “Double Top and Double Bottom patterns” a veces reaccionan en lo que busco, por eso lo que me gustaría obtener es un Screener donde en gráfico de 1 hora cualquiera de los dos indicadores (no tiene por que dar señal ambos, con uno bastaría) “Wick Pressure Zones” o el “Double Top and Double Bottom patterns” me alerten, pero al mismo tiempo en gráfico diario el indicador “Fibonacci Structure Engine” se encuentra en la tendencia (alcista o bajista) en la “zona dorada”; dando por hecho de que si por ejemplo en el intradía se produce un doble suelo o una vela alcista del Wick Pressure y en diario, el indicador principal se encuentra en tendencia bajista, la alerta no se produciría. Bien, creo que me expliqué bien de lo que deseo, otra cosa es que por el tema de confluir distintas temporalidades a la vez esto se pueda conseguir, de ser posible para mí sería muy importante, a continuación dejo los tres indicadores:
//----------------------------------------------------------//
//PRC_Double Top and Bottom
//version = 0
//16.07.2024
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//----------------------------------------------------------//
//-----inputs
prd = 5
tol = 15
showPivot=1
Show2Bot=1
Show2Top=1
ShowShort=1
ShowLong=1
src1 = low
src2 = high
//----------------------------------------------------------//
//-----Pivots High&Low--------------------------------------//
ph = high=highest[prd](high)
pl = low=lowest[prd](low)
//----------------------------------------------------------//
//-----Direction Calculation--------------------------------//
if ph and pl=0 then
dir=1
elsif pl and ph=0 then
dir=-1
else
dir=dir
endif
dirchanged=dir<>dir[1]
//----------------------------------------------------------//
//-----Calculate Arrays for each pivot----------------------//
if ph or pl then
if dirchanged then
if dir=1 then
$zigzag[t+1]=highest[prd](high)
$zigzagidx[t+1]=barindex
$dir[t+1]=1
t=t+1
elsif dir=-1 then
$zigzag[t+1]=lowest[prd](low)
$zigzagidx[t+1]=barindex
$dir[t+1]=-1
t=t+1
endif
else
if dir=1 and highest[prd](high)> $zigzag[t] then
$zigzag[t]=highest[prd](high)
$zigzagidx[t]=barindex
elsif dir=-1 and lowest[prd](low)< $zigzag[t] then
$zigzag[t]=lowest[prd](low)
$zigzagidx[t]=barindex
endif
endif
endif
//----------------------------------------------------------//
if t>4 then
//-----Double Top pattern----------------------------//
htop=($zigzag[t-3]+$zigzag[t-1])/2-$zigzag[t-2]
TopHigh=$zigzag[t-3]+htop*tol/100
BotHigh=$zigzag[t-3]-htop*tol/100
DoubleTop=($zigzag[t-1]>=BotHigh and $zigzag[t-1]<=TopHigh) and ($zigzag[t-3]>y1 and $zigzag[t-3]>$zigzag[t-2] and $zigzag[t-1]>$zigzag[t-2])
if DoubleTop and not DoubleTop[1] then
checkTop=1
short=0
x1=$zigzagidx[t-4]
y1=$zigzag[t-4]
x2=$zigzagidx[t-3]
y2=$zigzag[t-3]
x3=$zigzagidx[t-2]
y3=$zigzag[t-2]
x4=$zigzagidx[t-1]
y4=$zigzag[t-1]
x5=$zigzagidx[t]
y5=$zigzag[t]
dist=abs(y3-min(y2,y4))
if Show2Top then
drawrectangle(x2,y2,x4,y4)coloured("red")fillcolor("red",50)
endif
endif
if checkTop and ShowShort then
if not short and close crosses under y3 then
short=1
tpsh=(y3-dist)
slsh=max(y2,y4)
drawarrowdown(barindex,high)coloured("blue")
drawsegment(x3,y3,barindex,y3)coloured("blue")
endif
if short and low crosses under tpsh then
short=0
checkTop=0
Drawsegment(x3,tpsh,barindex,tpsh)coloured("blue")style(dottedline)
drawarrowup(barindex,low)coloured("orange")
endif
if short and close crosses over slsh then
checkTop=0
short=0
Drawsegment(x4,slsh,barindex,slsh)coloured("blue")style(dottedline)
drawarrowup(barindex,low)coloured("orange")
endif
endif
//-----Double Bottom pattern------------------------//
hbot=$zigzag[t-2]-($zigzag[t-3]+$zigzag[t-1])/2
topLow=$zigzag[t-3]+hbot*tol/100
botLow=$zigzag[t-3]-hbot*tol/100
DoubleBot=($zigzag[t-1]>=botLow and $zigzag[t-1]<=toplow) and ($zigzag[t-3]<$zigzag[t-4] and $zigzag[t-3]<$zigzag[t-2] and $zigzag[t-1]<$zigzag[t-2])
if DoubleBot and not DoubleBot[1] then
checkBot=1
xx1=$zigzagidx[t-4]
yy1=$zigzag[t-4]
xx2=$zigzagidx[t-3]
yy2=$zigzag[t-3]
xx3=$zigzagidx[t-2]
yy3=$zigzag[t-2]
xx4=$zigzagidx[t-1]
yy4=$zigzag[t-1]
xx5=$zigzagidx[t]
yy5=$zigzag[t]
dist1=abs(yy3-min(yy2,yy4))
if Show2Bot then
drawrectangle(xx2,yy2,xx4,yy4)coloured("green")fillcolor("green",50)
endif
endif
if checkbot and ShowLong then
if not long and close crosses over yy3 then
long=1
tp=yy3+dist1
sl=min(yy2,yy4)
drawarrowup(barindex,low)coloured("green")
drawsegment(xx3,yy3,barindex,yy3)coloured("blue")
endif
if long and high crosses over tp then
long=0
checkBot=0
Drawsegment(xx3,tp,barindex,tp)coloured("blue")style(dottedline)
drawarrowdown(barindex,high)coloured("red")
endif
if long and close crosses under sl then
checkBot=0
long=0
Drawsegment(xx4,sl,barindex,sl)coloured("blue")style(dottedline)
drawarrowdown(barindex,high)coloured("red")
endif
endif
endif
//-----Draw Pivots------------------------------------------//
if islastbarupdate and showPivot then
for i=t downto 4 do
drawpoint($zigzagidx[i],$zigzag[i],2)coloured("blue",100)
next
endif
//----------------------------------------------------------//
return
---------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------
//PRC_Wick Pressure Zones by BigBeluga
//version = 0
//09.09.2025
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//---------------------------------------------------
DEFPARAM DrawOnLastBarOnly = true
//---------------------------------------------------
// inputs
//---------------------------------------------------
lookback = 200
threshold = 80
extendBars = 20
maxLevels = 10
rsiLen = 14
upR = 255
upG = 0
upB = 0
dnR = 0
dnG = 255
dnB = 0
//---------------------------------------------------
// Variables auxiliares
//---------------------------------------------------
bodyTop = MAX(open, close)
bodyBot = MIN(open, close)
// Mechas relativas (evitar división por 0)
denUp = MAX(bodyTop, 0.0000001)
denLo = MAX(low, 0.0000001)
upperWick = (high - bodyTop) / denUp
lowerWick = (bodyBot - low) / denLo
maxUpper = HIGHEST[lookback](upperWick)
maxLower = HIGHEST[lookback](lowerWick)
sizeUpWick = 0
sizeLoWick = 0
IF maxUpper > 0 THEN
sizeUpWick = FLOOR( (upperWick / maxUpper) * 100 )
ENDIF
IF maxLower > 0 THEN
sizeLoWick = FLOOR( (lowerWick / maxLower) * 100 )
ENDIF
//---------------------------------------------------
myrsi = RSI[rsiLen](close)
vol = volume
//---------------------------------------------------
// Separación mínima entre zonas
ONCE startidx = -100000
//---------------------------------------------------
// Boxes
//---------------------------------------------------
ONCE n = 0
newUpper = sizeUpWick >= threshold AND NOT (sizeLoWick >= threshold) AND myrsi > 50 AND (BarIndex - startidx > extendBars)
newLower = sizeLoWick >= threshold AND NOT (sizeUpWick >= threshold) AND myrsi < 50 AND (BarIndex - startidx > extendBars)
// Crear zona superior
IF newUpper THEN
startidx = BarIndex
n = n + 1
$side[n] = 1
$left[n] = BarIndex - 1
$top[n] = high
$bot[n] = bodyTop
$right[n] = barindex + 1
$broken[n] = 0
$volume[n] = volume
// Límite de zonas: mantener sólo las más recientes
IF n > maxLevels THEN
// Shift a la izquierda
FOR k = 1 TO n - 1 DO
$side[k] = $side[k+1]
$left[k] = $left[k+1]
$top[k] = $top[k+1]
$bot[k] = $bot[k+1]
$right[k] = $right[k+1]
$broken[k] = $broken[k+1]
$volume[k] = $volume[k+1]
NEXT
n = maxLevels
ENDIF
ENDIF
// Crear zona inferior
IF newLower THEN
startidx = BarIndex
n = n + 1
$side[n] = -1
$left[n] = BarIndex - 1
$top[n] = bodyBot
$bot[n] = low
$right[n] = barindex + 1
$broken[n] = 0
$volume[n] = volume
IF n > maxLevels THEN
FOR k = 1 TO n - 1 DO
$side[k] = $side[k+1]
$left[k] = $left[k+1]
$top[k] = $top[k+1]
$bot[k] = $bot[k+1]
$right[k] = $right[k+1]
$broken[k] = $broken[k+1]
$volume[k] = $volume[k+1]
NEXT
n = maxLevels
ENDIF
ENDIF
//---------------------------------------------------
// DIBUJO y GESTIÓN
//---------------------------------------------------
IF islastbarupdate THEN
FOR i = 1 TO n DO
for j=barindex-$right[i] downto 0 do
IF $side[i] = 1 AND low[j] > $top[i] THEN
$broken[i] = 1
$right[i] = barindex[j]
break
ELSIF $side[i] = -1 AND high[j] < $bot[i] THEN
$broken[i] = 1
$right[i] = barindex[j]
break
ENDIF
next
vol=$volume[i]
if $broken[i]=1 and $side[i]=1 then
drawrectangle($left[i],$bot[i],$left[i]+2,$top[i])coloured("red")
drawsegment($left[i],$top[i],$right[i],$top[i])coloured("grey",125)style(line,3)
ELSIF $broken[i]=0 AND $side[i]=1 THEN
leftX = $left[i]
rightX = barindex
topY = $top[i]
botY = $bot[i]
height = ABS(topY - botY)
IF height > 0 THEN
steps = 10
stepH = height / steps
DRAWRECTANGLE(leftX, topY, leftX + 2, botY) COLOURED(upR,upG,upB)
FOR s = 0 TO steps - 1 DO
segBot = botY + stepH * s
segTop = segBot + stepH
alphaVal = 30 + s * 12
IF s = steps - 1 THEN
alphaVal = 160
ENDIF
DRAWRECTANGLE(leftX, segTop, rightX, segBot) COLOURED(upR,upG,upB, 0)fillcolor(upR,upG,upB, alphaVal)
NEXT
midY = botY + height * 0.5
DRAWTEXT("#vol#", rightX, midY)
ENDIF
elsif $broken[i]=1 and $side[i]=-1 then
drawrectangle($left[i],$bot[i],$left[i]+2,$top[i])coloured("green")
drawsegment($left[i],$bot[i],$right[i],$bot[i])coloured("grey",125)style(line,3)
ELSIF $broken[i]=0 AND $side[i]=-1 THEN
leftX = $left[i]
rightX = barindex
topY = $top[i]
botY = $bot[i]
height = ABS(topY - botY)
IF height > 0 THEN
steps = 10
stepH = height / steps
DRAWRECTANGLE(leftX, topY, leftX + 2, botY) COLOURED(dnR,dnG,dnB)
FOR s = 0 TO steps - 1 DO
segBot = botY + stepH * s
segTop = segBot + stepH
alphaVal = 160 - s * 12
IF s = 0 THEN
alphaVal = 160
ENDIF
DRAWRECTANGLE(leftX, segTop, rightX, segBot) COLOURED(dnR,dnG,dnB, 0)fillcolor(dnR,dnG,dnB, alphaVal)
NEXT
midY = botY + height * 0.5
DRAWTEXT("#vol#", rightX, midY)
ENDIF
endif
NEXT
ENDIF
RETURN
---------------------------------------------------------------------------------------------
//----------------------------------------------------------
// PRC_FIBONACCI STRUCTURE ENGINE
// Original: WillyAlgoTrader (PineScript v6)
// version = 2
// 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 fibDir = 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
fibDir = 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
fibDir = -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 and fibDir <> 0 then
fibValid = 1
fibRng = fibHigh - fibLow
if fibDir = 1 then
// BULLISH: retracement from top toward low, targets ABOVE high
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
fibTgt50 = fibHigh + fibRng * 0.5
fibTgt618 = fibHigh + fibRng * 0.618
else
// BEARISH: retracement from bottom toward high, targets BELOW low
fib236 = fibLow + fibRng * 0.236
fib382 = fibLow + fibRng * 0.382
fib500 = fibLow + fibRng * 0.500
fib618 = fibLow + fibRng * 0.618
fib786 = fibLow + fibRng * 0.786
fibTgt50 = fibLow - fibRng * 0.5
fibTgt618 = fibLow - fibRng * 0.618
endif
endif
// ═══════════════════════════════════════
// PREMIUM / DISCOUNT
// ═══════════════════════════════════════
inPremium = 0
inDiscount = 0
if fibValid = 1 then
if fibDir = 1 then
// Bullish: premium = above 0.5, discount = below 0.5
if close > fib500 then
inPremium = 1
else
inDiscount = 1
endif
else
// Bearish: premium = below 0.5 (overextended down), discount = above 0.5 (retracement up)
if close < fib500 then
inPremium = 1
else
inDiscount = 1
endif
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)
gzTop = max(fib500, fib786)
gzBot = min(fib500, fib786)
drawrectangle(barindex, gzTop, rightEdge, gzBot) 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)
IF fibDir = 1 THEN
drawtext("Target ↑", rightEdge + 2, fibTgt618) coloured(0, 230, 118)
ELSE
drawtext("Target ↓", rightEdge + 2, fibTgt618) coloured(255, 82, 82)
ENDIF
endif
if showFibT50 = 1 then
drawsegment(barindex, fibTgt50, rightEdge, fibTgt50) coloured(tgtR2, tgtG2, tgtB2) style(dottedline, 1)
IF fibDir = 1 THEN
drawtext("-0.5 ↑", rightEdge + 2, fibTgt50) coloured(0, 230, 118)
ELSE
drawtext("-0.5 ↓", rightEdge + 2, fibTgt50) coloured(255, 82, 82)
ENDIF
endif
// Target zone box
IF showFibTgt = 1 OR showFibT50 = 1 THEN
tzTop = max(fibTgt50, fibTgt618)
tzBot = min(fibTgt50, fibTgt618)
IF fibDir = 1 THEN
tzR = 0
tzG = 230
tzB = 118
ELSE
tzR = 255
tzG = 82
tzB = 82
ENDIF
drawrectangle(barindex, tzTop, rightEdge, tzBot) coloured(tzR, tzG, tzB) fillcolor(tzR, tzG, tzB, 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"
Buenas. Estuve intentando ver cómo hacerlo pero no lo consiguo… cuando se trabaja con arrays en screeners es complejo porque hay limitaciones de velas y a veces los resultados obtenidos no cuadran. La solucion sería simplificar todo
Screeners confluyendo en distinto horario
This topic contains 1 reply,
has 2 voices, and was last updated by
Iván González
1 day ago.
| Forum: | ProScreener: Buscadores de Mercado y Rastreo |
| Language: | Spanish |
| Started: | 04/16/2026 |
| Status: | Active |
| Attachments: | No files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.