Iván González

Sweep Reversal Map Screener

Category: Screeners By: Iván González Created: November 20, 2026, 5:50 PM
November 20, 2026, 5:50 PM
Screeners
0 Comments
Sweep Reversal Map Screener

Introduction

 

Scanning for liquidity sweeps is easy and almost useless. Every swing high in every market gets taken out sooner or later, and a screener built on that alone hands you a list as long as your universe, most of it price simply continuing on its way.

The list only becomes worth reading when the sweep has been contradicted. This screener returns the instruments where a swing level was taken out, price closed back through it, and then broke the structure that existed before the raid – all inside a fixed deadline. The ones that did not manage it never appear.

It is the scanning companion to the Sweep Reversal Map indicator (https://www.prorealcode.com/prorealtime-indicators/sweep-reversal-map/): the same engine, the same conditions, so every instrument on the list has a drawn, confirmed zone waiting on its chart.

What the Screener Is Actually Testing

 

Three things have to line up, in this order.

A level that has not been used. A swing pivot with swingLen bars on each side. Once it is swept, it is consumed – the same high cannot generate a second candidate no matter how many times price returns to it. Without that rule a level price is hovering around would fire on every bar.

A sweep. The bar’s high goes beyond the swing high by at least minPen times ATR. Three values are captured at that instant and never recalculated: the swept level, the structure level (the lowest low of the structLen bars before the sweep bar), and the running extreme of the raid.

Freezing the structure level is the part that makes the whole thing work. The bar that goes hunting for stops is usually a big bar, and a big bar drags the recent extremes with it. If the level to break moved along with price, the sweep would be lowering its own hurdle.

A confirmation, within maxConfBar bars. Price has to have closed back on the right side of the swept level (the reclaim – without it you are looking at a breakout, not a sweep), then close beyond the frozen structure level, on a candle whose body is at least minDisp times ATR. Miss the deadline and the candidate is discarded silently.

Reading the Columns

 

Dir is 1 for a bullish reversal (a low was swept) and -1 for a bearish one.

Level is the swept swing level in price terms. It is the edge of the zone the indicator draws, and the natural reference for a stop.

Depth is how far beyond the level the sweep reached, measured in ATR. A high value means a long wick: the raid was aggressive and a lot of stops were taken before price turned.

Body is the body of the confirming candle in ATR. This is the column to sort by. The structure break is a weak filter by default – with structLen at 3 the level to clear sits very close – so the displacement is what really separates a reversal from a candle that happened to close red.

Span is how many bars passed between the sweep and the confirmation. Zero means price reversed inside the sweep bar itself, which is the cleanest version of the pattern. Larger values mean the market took its time, and the setup is correspondingly looser.

Bars ago is the age of the confirmation. With lookback at zero the list only contains fresh ones and this column is always zero; raise lookback to see the last few days at once.

One Thing to Know About Timing

 

The engine evaluates the last closed bar, which is what the indicator draws. That means Bars ago = 0 refers to the bar before the last one on the chart, not to the live candle.

This is deliberate. A screener that looked at the live bar would return instruments whose zone has not been drawn yet – and worse, instruments whose setup unwinds before the candle closes. Keeping the scan one bar behind the tape is what guarantees that everything on the list is visible on the chart when you open it.

The Code

 

//---------------------------------------------------------------
//PRC_Sweep Reversal Map Screener
//version = 0
//02.09.26
//Iván González @ www.prorealcode.com
//Author: Herman
//Sharing ProRealTime knowledge
//--------------------------------------------------------------------//
// Filters instruments where a liquidity sweep has just been CONFIRMED as a
// reversal by the PRC_Sweep-Reversal-Map indicator: a swing high (or low) was
// taken out, price closed back through it, and within maxConfBar bars it closed
// beyond the structure that existed BEFORE the sweep, with a real body.
//
// The engine below is copied VERBATIM from the indicator. Only the drawing is
// gone: the ring buffer, the pivot X coordinates and the style block. No state,
// no transition and no invalidation has been removed - trimming any of them
// would put the list and the chart on different counts.
//
// Like the indicator, the engine evaluates the last CLOSED bar. That is the bar
// the indicator draws, so "Bars ago = 0" means the bar BEFORE the last one on
// the chart, not the live candle.
//
// No DEFPARAM (not allowed in screeners).
//
// Output columns:
//   Dir       1 = bullish reversal (a low was swept), -1 = bearish (a high was)
//   Level     the swept swing level
//   Depth     how far beyond the level the sweep reached, in ATR
//   Body      body of the confirming candle, in ATR
//   Span      bars from the sweep to the confirmation (0 = same bar)
//   Bars ago  bars since the confirmation (0 = last evaluated bar)

//=== INPUTS: detection (same defaults as the indicator) ===
swingLen = 5      // bars on each side required to confirm a swing (2..50)
atrLen = 14       // ATR period used by the penetration and displacement filters
minPen = 0.0      // minimum penetration beyond the level, in ATR (0 = any breach)

//=== INPUTS: confirmation ===
structLen = 3     // bars before the sweep that define the local structure level
maxConfBar = 12   // maximum bars between the sweep and the confirmation
minDisp = 0.2     // minimum confirmation body, in ATR (0 = filter off)

//=== INPUTS: screener ===
dirMode = 0       // 0 = both sides, 1 = bullish only, 2 = bearish only
lookback = 0      // 0 = confirmed on the last evaluated bar; N = within the last N bars

//=== PERSISTENT STATE (verbatim from the indicator) ===
pivWin = 2 * swingLen + 1

once swHiOk = 0        // a fresh swing high is waiting to be swept
once swLoOk = 0
once lastSwHi = 0
once lastSwLo = 0
once bearOn = 0        // a bearish candidate is alive
once bearRec = 0       // price has already closed back below the swept level
once bearStart = 0
once bearLev = 0
once bearExt = 0
once bearCfLev = 0
once bullOn = 0
once bullRec = 0
once bullStart = 0
once bullLev = 0
once bullExt = 0
once bullCfLev = 0

//=== SERIES ===
atrRaw = averagetruerange[atrLen](close)
pivHi = highest[pivWin](high)
pivLo = lowest[pivWin](low)
strLo = lowest[structLen](low)
strHi = highest[structLen](high)

// first bar on which every window the engine needs is complete
wUp = max(2 * swingLen, structLen)

//=== ENGINE (verbatim from the indicator) ===
// The engine has to advance exactly once per CLOSED bar. ProRealTime recomputes
// the live bar on every tick, so it is fed with the last closed bar: every read
// and every anchor is shifted one bar TOGETHER, condition and coordinate always
// belonging to the same candle. That closed bar is exactly what the indicator
// draws, so the list and the chart cannot end up on different counts.
// Signal series, written on EVERY bar so that sigXxx[k] has history from bar 0.
// Bull and bear can NEVER fire on the same bar: a bearish confirmation needs a
// close below the prior structLen low and a bullish one a close above the prior
// structLen high, and the low is never above the high.
sigBull = 0
sigBear = 0
sigLev = 0
sigSpan = 0
sigDpth = 0
sigBody = 0

if barindex > wUp then

   cIdx = barindex - 1
   cHigh = high[1]
   cLow = low[1]
   cClose = close[1]
   cBody = abs(close[1] - open[1])

   // ATR is undefined during its warmup: it counts as zero for the penetration
   // and it switches the displacement filter off until it exists.
   atrOk = 0
   atrV = 0
   if atrRaw[1] <> undefined then
      atrOk = 1
      atrV = atrRaw[1]
   endif
   penAbs = atrV * minPen
   dispOk = 0
   if atrOk = 1 and cBody >= atrV * minDisp then
      dispOk = 1
   endif

   // ATR divider for the output columns. ATR can only be 0 on a flat instrument,
   // and dispOk already blocks every confirmation while it is undefined.
   atrDiv = atrV
   if atrDiv <= 0 then
      atrDiv = 1
   endif

   // structure of the structLen bars that PRECEDE the closed bar
   priorLow = strLo[2]
   priorHigh = strHi[2]

   // --- confirmed swings, swingLen bars on each side ---
   if high[swingLen + 1] = pivHi[1] then
      lastSwHi = high[swingLen + 1]
      swHiOk = 1
   endif
   if low[swingLen + 1] = pivLo[1] then
      lastSwLo = low[swingLen + 1]
      swLoOk = 1
   endif

   // --- bearish candidate: price sweeps a confirmed swing high ---
   if bearOn = 0 and swHiOk = 1 and cHigh >= lastSwHi + penAbs then
      bearOn = 1
      bearRec = 0
      if cClose < lastSwHi then
         bearRec = 1
      endif
      bearStart = cIdx
      bearLev = lastSwHi
      bearExt = cHigh
      bearCfLev = priorLow
      swHiOk = 0
   endif

   if bearOn = 1 then
      bearExt = max(bearExt, cHigh)
      if cClose < bearLev then
         bearRec = 1
      endif
      if bearRec = 1 and cClose < bearCfLev and dispOk = 1 then
         sigBear = 1
         sigLev = bearLev
         sigSpan = cIdx - bearStart
         sigDpth = (bearExt - bearLev) / atrDiv
         sigBody = cBody / atrDiv
         bearOn = 0
      elsif cIdx - bearStart > maxConfBar then
         bearOn = 0
      endif
   endif

   // --- bullish candidate: price sweeps a confirmed swing low ---
   if bullOn = 0 and swLoOk = 1 and cLow <= lastSwLo - penAbs then
      bullOn = 1
      bullRec = 0
      if cClose > lastSwLo then
         bullRec = 1
      endif
      bullStart = cIdx
      bullLev = lastSwLo
      bullExt = cLow
      bullCfLev = priorHigh
      swLoOk = 0
   endif

   if bullOn = 1 then
      bullExt = min(bullExt, cLow)
      if cClose > bullLev then
         bullRec = 1
      endif
      if bullRec = 1 and cClose > bullCfLev and dispOk = 1 then
         sigBull = 1
         sigLev = bullLev
         sigSpan = cIdx - bullStart
         sigDpth = (bullLev - bullExt) / atrDiv
         sigBody = cBody / atrDiv
         bullOn = 0
      elsif cIdx - bullStart > maxConfBar then
         bullOn = 0
      endif
   endif

endif

//-------------------------------------------------------------//
//--- Direction filter, applied to the signal of every bar ---
//-------------------------------------------------------------//
sigOk = 0
if dirMode = 0 and (sigBull = 1 or sigBear = 1) then
   sigOk = 1
elsif dirMode = 1 and sigBull = 1 then
   sigOk = 1
elsif dirMode = 2 and sigBear = 1 then
   sigOk = 1
endif

//-------------------------------------------------------------//
//--- Most recent confirmation inside the lookback window ---
//-------------------------------------------------------------//
sigFound = 0
sigAge = 0
dirOut = 0
lvlOut = 0
spanOut = 0
depthOut = 0
bodyOut = 0
for kk = 0 to lookback do
   if sigFound = 0 and sigOk[kk] = 1 then
      sigFound = 1
      sigAge = kk
      if sigBull[kk] = 1 then
         dirOut = 1
      else
         dirOut = 0 - 1
      endif
      lvlOut = sigLev[kk]
      spanOut = sigSpan[kk]
      depthOut = round(sigDpth[kk] * 100) / 100
      bodyOut = round(sigBody[kk] * 100) / 100
   endif
next

SCREENER[sigFound = 1](dirOut AS "Dir", lvlOut AS "Level", depthOut AS "Depth", bodyOut AS "Body", spanOut AS "Span", sigAge AS "Bars ago")

Settings

 

The detection and confirmation blocks carry the same defaults as the indicator, and they should stay in sync: change one and you change which instruments the list agrees with.

swingLen (5) sets how significant a level has to be. minPen (0.0) is the minimum push beyond it in ATR – at zero, touching counts. structLen (3) is the number of bars before the sweep that define the level to break; it is the most permissive default in the whole tool, and raising it towards swingLen makes a confirmation mean considerably more. maxConfBar (12) is the deadline, and minDisp (0.2) the minimum body of the confirming candle.

Two settings belong to the screener itself. dirMode is 0 for both sides, 1 for bullish reversals only, 2 for bearish only. lookback is 0 for confirmations on the last evaluated bar, or N to accept anything inside the last N bars, with Bars ago telling you when.

If the list comes back too long, tighten in this order: minDisp first (0.3 to 0.4), then structLen, then minPen. Loosening maxConfBar in the other direction is rarely worth it – a reversal that needs twelve bars to show up is not really reacting to the sweep.

Notes and Limitations

 

  • The engine is the indicator’s, unabridged. Every state, transition and expiry was kept. A screener trimmed down to “just the signal condition” drifts away from the chart the first time the two take different branches, and after that the list means nothing.
  • History window. ProScreener works on 255 bars with a Complete subscription and 1024 with Premium, while the chart may hold far more. Here the exposure is small: no state survives more than a few dozen bars, since a candidate lives at most maxConfBar bars and the pivot sits about 2 x swingLen back. The one long-lived item is the pending swing level, which persists until something sweeps it.
  • Adjusted prices. ProScreener uses dividend-adjusted prices for stocks and your chart may not be adjusted the same way. If a Level does not match the chart to the cent on a US stock, look there before looking at the code.
  • Intraday units need real-time data; without them the unit list stops at daily.
  • Nothing is scored. A raid on a level respected six times over three weeks and a raid on a two-day-old swing produce identical rows. Volume is not consulted.

Conclusion

 

A sweep on its own is not information – it is the most common thing that happens to a swing high. What carries information is a sweep the market immediately contradicted, and the only way to know that is to freeze what “contradicted” means at the moment of the raid and then give price a deadline.

Sort the output by Body, check that Span is small, and you have a short list of markets where liquidity was taken and immediately handed back.

Download
Filename: SCR_Sweep-Reversal-Map.itf
Downloads: 1
Iván González
Iván González Legend
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...