OPEN-SOURCE SCRIPT
Actualizado

ERL x IRL PO3 (M1D)

2 136
ERL x IRL PO3
Tracks one ICT sequence from start to finish: a dealing range on a higher timeframe, one side of it raided, a market structure shift on the chart, and then the PD arrays the reversal leaves behind, counted one by one into a grade. It draws the sequence as it happens and reports where you are in it. It is not a signal generator: nothing fires, and the entry is left to you.

What it does

1 · Dealing range.
The range is found on a higher timeframe — 4H by default; 1H, 6H, Daily and Weekly are options — and followed at chart scope, so every level is anchored on the chart bar that actually printed it. It forms once, from the highest and lowest swings inside the lookback, and then it holds: sweeps, internal swings and lower highs inside it do not touch it. Both sides draw as soon as it exists — the buyside and sellside liquidity, each labelled as the external range liquidity it is, extending to the right edge. It rebuilds only after a close through a side, judged on the range timeframe's candles with the same allowance the sweep uses: the broken side stays in grey, marked broken; the last swing before the breaking leg becomes the new far side; and the new near side forms on price as a dotted line until the range timeframe confirms a swing there, then locks. The thirds are available as dotted lines, and the console names where price sits in them.

2 · Sweep.
A wick through one side is the raid. The level belongs to the range timeframe, so the reclaim is judged there: price may close beyond the level on the chart, but not for longer than a set number of range candles, one by default. Reclaim inside that and it is a sweep; stay beyond it and it is a break. On the raid the swept side freezes as a dotted, spent line with a Sweep tag on the outside of the level — below a sellside raid, above a buyside one — and the other side is now the draw, and says so. A sweep must cross the level from inside: price sitting beyond a level after a break is never re-read as a fresh raid. An optional failed push at the far side can be required first.

3 · Market structure shift. The gate. After the sweep, the latest chart swing inside the range is the structure to break. The shift confirms on a close through it that is also back inside the swept level, and the leg from the sweep extreme to that close has to clear a displacement floor — the V — or the script keeps waiting rather than calling a grind a shift. The reference swing draws as a short solid line to the break bar, labelled MSS at the swing on its outside; it stops at the break so it is never mistaken for a level. Nothing internal is drawn before this point. An optional New York session window — RTH, the AM killzone or the PM session — restricts which shifts count; it is off by default so the whole chart can be scanned, and on for live alerts it keeps them to the session you trade.

4 · PD arrays and grade. Once the shift confirms, six candidates are counted as they form, each once:

— the displacement gap, +FVG or −FVG, with its consequent encroachment; — the volume imbalance; — the suspension block, drawn with a hard border and its midline; — the inversion gap, an opposite-direction gap the leg closed through; — the breaker; — the optimal trade entry band, 0.62 to 0.79 of the leg.

Absorption keeps one leg from counting twice: a suspension block replaces the gap and the imbalance of its own triplet, and a gap absorbs an imbalance on either of its seams. The OTE is measured the way it is drawn by hand: from the leg's own low or high — the extreme between just before the raid and the shift, not the sweep wick alone — to the first two-candle swing after the shift, a high the next candle does not exceed or a low it does not undercut. It fires when that swing confirms, not on a touch, and a dotted grey diagonal from the leg's start to its end shows the range being measured. By default the band stays at that first swing; a setting lets it follow higher swings until price has traded into it. The band is blackish grey, because it is a measurement rather than a directional array. The breaker uses the failed-block reading shared with the Unicorn Model and the Confluence Engine: an order block exists only where a displacement candle against the setup, with a real body, closed through the last chart swing and left a gap around it, and the block is the run of opposite-close candles immediately before it, wick to wick. It becomes the breaker only when a close passes back through it — the block fails and flips in place, the way a gap inverts. A block price never closed through is an order block and never a breaker. The grade is a count: three arrays for A, four for A+, both inputs. It rides on the draw's own label at the right edge — BSL · ERL · 15m A+ — so no grade tag sits inside price. When the setup ends, taken or retired, the draw line stops dotted and the grade moves to the target's swing, one ATR clear of the line, so it reads as history without sitting on price. An array a close trades through is removed from the chart; the count stands, because the array did form.

5 · Three assets, one draw. On NQ, ES and YM, micros included, the peers are read against the same range. The console reports whether each has taken the draw, names the laggard — the one still to move is the trade — and, when the chart is the laggard, watches for a catch-up gap on a 1H or 30m confirmation timeframe. A SMT is read on the bar it forms: when the chart sweeps a level and a peer holds its own, a solid line runs from the range swing to the sweep extreme — the chart's lower low against the peer's higher low — and the Sweep tag names the peer that held: Sweep · SMT YM. If every peer later takes its level the line is removed and the tag reverts, because the divergence failed.

6 · PO3 candle.
The live candle of the range timeframe, drawn beside price as a proper candle with a hard border and wicks, offset to the right so it clears the level labels, with its open, high, low and close carried back as lines and tagged. A PO3 price that sits on a live range level merges into that level's label, so nothing stacks. Hidden when the chart is not below the range timeframe.

7 · Console. Two named columns, all in ink. Under the chart timeframe: the verdict and grade; the range and where price sits in it; the draw with its distance and the risk-to-reward from the nearest array; Sweep · MSS · OTE as three ticks. Under the two peers: the draw check; which peers have taken the draw, with any SMT; the catch-up gap when the chart lags; the last completed setup; the range candle's countdown and range. Silent rows are dropped.

Visual grammar

Purple marks bullish arrays, magenta bearish; liquidity, structure and text are black, and the consequent encroachment is dotted grey. A live level is solid; a spent one is dotted. Gaps fill at a light opacity you set; blocks carry a hard border. Every label sits in clear air by construction, not by luck: a level's name sits at the swing that made the level, on its outside — above a high, below a low — where nothing has traded; the Sweep tag at the raid's wick, the same way; the MSS at its reference swing; the OTE bold in the middle of its band; the live range names and every zone caption at the right edge past the last candle. The OTE band is blackish grey. Arrays price has closed through are removed, not faded, and the last five setups per direction stay on the chart as history.

Method & repainting

Every detection path — the range swings, the sweep and its reclaim, the shift, every array, the breaker search and the peer reads — evaluates on closed bars only. The range timeframe is followed at chart scope with no security call, so a range level is fixed to the bar that printed it and never moves. The peers and the catch-up timeframe are read from completed candles with a non-repainting call; the peers are also read on the chart timeframe, on closed bars, so a SMT resolves on the bar it forms. Swings confirm a set number of bars after they print; that is a fixed delay, not a revision.

Two things update live. The console reads current price, and the PO3 candle is the forming candle of the range timeframe, rebuilt on every tick and never left as history.

Settings

Range timeframe, swing strength, lookback and minimum size; the reclaim allowance, sweep expiry, setup retirement and how many setups to keep; the displacement floor; the session window; the gap height floor, OTE band, breaker drawing mode and order-block body; the grade thresholds and minimum risk-to-reward; the peer cross-check and catch-up timeframe; every drawn element individually; the PO3 candle; label size, right offset and fill opacities. Eight alerts: bullish and bearish shift, grade A, grade A+, and the catch-up gap.

Disclaimer

This is a decision-support tool for discretionary ICT trading. It is not financial advice, and no market's past behaviour is indicative of future results.
Notas de prensa
The wrong build went up with the first publication. This is the corrected one.
Two things in the uploaded version did not match the description, and both are now as written.

The breaker searched too far back. The reading itself is unchanged — an order block exists only where a displacement candle closed through the last chart swing and left a gap behind it, and it becomes the breaker once a close passes back through it — but the search was allowed to walk sixty bars back from the sweep. On a low timeframe that is hours of price, so a block left by an earlier, unrelated move could be called this reversal's breaker when price eventually closed above it. The search now covers only the leg into the sweep, from the swing that leg came from to the sweep extreme. A leg that left no qualifying block has no breaker, and the grade does not get the point.

The OTE leg now ends at the range timeframe's swing. The uploaded build measured the leg to the first two-candle swing on the chart, which on a 5-minute chart can be a very small leg that no one would draw a fib to. The default is now the first swing the range timeframe confirms after the shift — the swing you would measure to on the higher timeframe. The chart's two-candle reading is kept as a setting, OTE leg ends at the first swing of, for anyone who wants the tighter leg.

Every default not named above is as it was, and nothing changes in how the range, the sweep, the shift, the peers or the console are found or drawn.
Notas de prensa
The SMT line now shows the divergence.
It was drawn from the range swing, which on an intraday chart can sit days back, so it ran flat under the level and never read as anything. It now runs from the last chart swing before the raid to the raid's extreme — the higher high (or lower low) the correlated market failed to match — and carries its own tag at that extreme naming which peer held.

The Sweep tag sits at the level.
It marks the candle that wicked through the level, on the level itself, and the dotted level line stops on that candle. Neither moves if price runs further afterwards; the sweep is the event at the level, not wherever the excursion topped out.

Fixed a crash on a 1-minute chart.
Every level here is anchored at the candle that set it, and on a 1-minute chart yesterday's swing sits well over a thousand bars back. The history buffer reserved for placing those anchors was sized for a 5-minute chart, so a lower timeframe could stop the script mid-session with "requested historical offset is beyond the historical buffer's limit". The buffer is now set to the maximum. Nothing changes in what is detected.
Notas de prensa
Resting liquidity, and a pool is a PAIRED level.
The dealing range drew its own two edges and nothing else. The new Liquidity pools group draws the pools between and beyond them, on the definition used by Liquidity Levels+: a swing pool exists only where TWO pivots rest at the same price within the tolerance, labelled REH or REL, keeping the more extreme of the two prices because that is the one a raid has to take out. A lone swing high is one candle, not resting liquidity, and it is not drawn. The tolerance is measured on the RANGE timeframe rather than the chart's — scaled to the chart it was smaller than a tick on a one-minute chart, which drew a band of near-identical highs as a line each instead of one pool. The previous day's and previous week's high and low are pools in their own right and carry their own names.

ERL stays outside the range. A pool resting between the two range edges is internal liquidity, already described by the edges themselves, and is not drawn. That is the whole distinction the script is named for, and drawing both filled the chart with lines that said nothing the range had not already said. A setting turns it off.

Liquidity that has been run comes off the chart.
Dotting a taken level says it is spent, but it is still a line being read as a draw — a four-hour buyside level sat dotted four hundred points above price on a retired setup. One setting now governs every piece of it together: the pools, both dealing range edges and the broken side. Taken liquidity is gone by default; switch it on and it stays dotted and grey as the record of where price has been.

A zone's name sits inside the zone. Every PD array caption — the gap, the volume imbalance, the suspension block, the inversion gap, the breaker — was hung off the right edge of its zone, where it read as belonging to whatever sat beside it, and on a zone a few ticks tall it printed through both of its own borders. Each caption is now centred in the zone it names and travels with it as the zone extends. The OTE band keeps its bold weight; the arrays are centred and plain.

Names clear their own lines. The draw target, the breaker, both range thirds and the price handle were centred vertically on the level they name, so the text printed along the line. They are corner-anchored now, above a buyside level and below a sellside one, beginning where the line stops.

Nothing else moves. Detection, the sweep and reclaim, the shift, grading, the OTE leg, the breaker search, the peer cross-check, the history and the console are untouched, and every existing setting keeps the value it had.
Notas de prensa
The level the shift has to break, on the chart while you are waiting for it. After a raid, the structure to break was only ever drawn once it had already broken. The new Display setting "The level a close must break for the MSS" marks it from the sweep onwards — the chart swing a close has to clear, dotted at the swing that made it and tagged MSS · pending, on the outside where nothing has traded. It is the same reference the confirmation itself tests, so it never marks a break the script would not accept, and it follows that reference as newer swings form. It is absent when the reference sits at or past the draw, because a break there is the draw rather than a shift. When the shift confirms, the solid MSS line replaces it exactly as before. Off by default.

Liquidity lines take a colour. "Liquidity line colour" sits beside the width setting in Style and covers the two dealing range sides, the swept level and the draw. It is black by default, which is what those four lines have always been. A range side left behind by a break stays grey so it still reads as spent, and every name stays black.

Two more alerts, at the raid rather than at the shift. "Sellside swept · watching for the MSS" and "Buyside swept · watching for the MSS" fire on the confirmed close that completes a raid — the same moment the pending level appears — so the chart can be looked at while the shift is still forming instead of after it has printed. The shift, grade and catch-up gap alerts are unchanged.

A raided level says so by being dotted, and the Sweep tag is gone. Solid is live and dotted is spent everywhere else in this script, and the raid was the one event paying for a label to say what the style already says. The tag is removed, and a raided side of the dealing range no longer returns to solid once the setup that raided it retires — which had it reading as though the level was never taken. The flags clear when a side moves, because that is the range rebuilding and not the same level being raided twice.

FINAL
Notas de prensa
The dealing range moves swing to swing
The range used to form once from the widest swings in the lookback and hold until a close went through a side, so on a weekly range the low could sit at a swing months old while a newer weekly low was the real external liquidity. Each side is now the latest swing the range timeframe has confirmed. The old behaviour is still there: "Hold the range until a close through a side" in Dealing range.

One setup per swing, and only with the SMT
The model is ERL taken, a close back inside, and a SMT at the sweep. The new Setup setting "MSS needs the SMT at the sweep" (on by default) turns away a raid where every peer took its own level too: nothing is drawn, and the same swing waits for a later raid that has the SMT. Once a swing has given a setup (the MSS confirmed), it cannot arm again, so setups no longer stack on one level. A new swing is needed for the next one. On symbols with no peers to read, the SMT is not required.

The chart is no longer empty between setups
Until now a gap, imbalance or block only appeared once a setup had confirmed and counted it, so most of a lower-timeframe chart showed nothing but the range. The +FVG, VI, SB+/SB-, IFVG and breakers now draw all the time, lighter than a setup's own arrays, nearest to price first. "Arrays per direction" (2) and "Arrays within (x ATR)" (8) in Display set how many and how far. Each kind still follows its own switch. An array a setup has counted is drawn by that setup and never a second time, and an array that overlaps one already drawn is skipped, so fills never stack into a solid block.

No more gaps across the weekend or the daily halt
The price jump from Friday's close to Sunday's open, or across the 17:00 halt, was being read as a fair value gap. Once price closed back through it, it became an IFVG hundreds of points tall. A gap now needs three consecutive bars, the same rule the VI and SB already followed. This also stops a setup counting one of those as its IFVG.

IFVG and breaker, read the same way the setup reads them
A gap that price closes through becomes an IFVG the other way, and it stays until a close goes back through its near edge. Every IFVG is now orange, on a setup and between setups, because orange means inverted; "Inversion colour (IFVG)" in Style changes it. The breaker is the order block the Unicorn reading finds: a displacement candle with a real body, closing through the last chart swing and leaving a gap. Once a close passes through the block it flips into a breaker. It is gone once a close goes back through its far side.

Swing structure on the chart
The chart swings the MSS is read from are tagged HH, HL, LH or LL at the candle that made them, outside the wick. "Swings per side" sets how many, the last two by default. A candle already named by a setup (the MSS, the sweep, the swept level, the draw) is not tagged again, and neither is a swing sitting inside a drawn array.

The level a close must break for the MSS is now on by default
It draws from the sweep until the shift prints, so you can see what the setup is waiting for.

Timers count hours, not bars
A sweep now expires after 12 hours without an MSS, and a live setup retires 24 hours after its MSS. The old bar counts meant about 12 hours on a 5m chart but 2.5 hours on a 1m and 3 days on a 30m, so the same setup lived or died depending on the timeframe. On 1H and above there is a floor of 16 and 32 bars so a daily chart does not expire a setup after one candle.

No more names stacked on one price
When several setups share a level, the newest one carries the name and the others go quiet. Setups that took the same draw now show one label with the best grade, for example "BSL · ERL · 5m A+", instead of identical labels printed on top of each other.

The range candle holds its shape on 1H and 4H
The candle beside price was placed by future time, and a weekend or the daily halt has no space on the chart, so on a 4H chart with a weekly range, or a 1H chart with a daily one, it could collapse into a flat outline with no body. It is now placed by bars. Its high and low lines run from the bar that opened the candle to the wick, the open to the body, and the close from the live bar to the body.

Relative equal highs and lows inside the range are drawn
A REH or REL between the two range edges is still resting liquidity and still a draw, so "External only - nothing inside the dealing range" in Liquidity pools is now off by default. Turn it on to see only the pools beyond the range.

One name per pool, and the day it came from
A previous day or week high or low now carries the date of its session, for example "BSL · PDH 15/09", so two days' highs no longer read as the same level. A pool sitting on top of another pool on the same side, or on a range edge, is not named a second time; the one nearer price keeps the name. Pool names no longer carry a touch count.

Previous day and week levels start at the candle that made them
A PDH, PDL, PWH or PWL line used to start at the opening time of the day or week, behind the candle that actually printed the high or low. It now starts at that chart candle.

A finished setup's target name stays with its line
Once a setup ends, its draw label sits at the end of its dotted line, outside the level, instead of floating above price.

The console is a framed table
A title row, names on the left in italic, values on the right in bold, black ink on white with a black grid.

Faster on lower timeframes
The script no longer rechecks every stored gap, pool and block on every bar. Each store remembers the nearest level price has to reach, and the full check runs only on a bar that reaches it. A setup waiting for a sweep rereads the dealing range only when the range or its swings change, and the MSS level is searched again only when a new chart swing confirms. What is drawn, and when, is unchanged.

No error with a single liquidity pool
With only one pool on the chart the nearest-first sort read past the end of its list and stopped the script. It now sorts safely with any number of pools.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.