OPEN-SOURCE SCRIPT

MSnR Double Breakout Level

11 363
MSnR Double Breakout Level

A staircase of turning points, and the level that matters once price finally runs out the top or
the bottom of it.

Support and resistance tools usually mark a level the moment it forms, which is why a chart ends up carrying dozens of lines that never meant anything. This one marks nothing when a level appears. It holds two of them, waits to see whether price runs past the pair, and only then draws the one that was left behind.

The result is that a level is never drawn on hope. By the time it is on the chart, price has
already proved it was willing to go through everything above or below it.


THE TWO BUILDING BLOCKS

A candle is green when close is above open, red when close is below. A doji, where they are
equal, is neither and takes no part.

A Level a green candle followed immediately by a red one.
The GREEN candle's CLOSE is the level.
Buyers pushed, sellers took it straight back.

V Level a red candle followed immediately by a green one.
The RED candle's CLOSE is the level.
Sellers pushed, buyers took it straight back.

These are not the output. They are the raw material.


DOUBLE BREAKOUT

Two same-side levels are held as a rolling pair. On the A side that is a descending pair - A1
above, A2 below:

A1 a close above this confirms it
A2 this is the level that gets marked

When a candle CLOSES above A1, the staircase has been run out, and A2 - the innermost step, the last place sellers stepped in before price left - is marked as the level.

The V side is the exact mirror. An ascending pair, V1 below and V2 above, a candle closing below V1, and V2 is marked.

It is always a DOUBLE. However long the staircase runs, only the latest two steps are ever held.
When a new same-side level appears while the pair is still waiting, one question decides what
happens to it:

the new level did NOT break the inner step -> the pair SLIDES one along
(old inner becomes the new outer)

the new level DID break the inner step -> the pair RESTARTS from that level

That single question is the whole bookkeeping, and it is the part most easily got wrong. Throwing the pair away every time another step appears loses the long staircases, which are exactly the ones worth waiting for. Never throwing it away means the pair drifts away from price and stops describing anything. Sliding keeps it anchored to the two most recent steps for as long as the move keeps going the same way, and restarts it the moment the move stops.

The breakout is always checked before any new level is. Reaching the outer step IS the breakout, so a level beyond it can only ever belong to the next search, never interrupt the current one.


DOUBLE BREAKOUT TO DOUBLE BREAKOUT

A completed Double Breakout can itself be taken out - by a completed Double Breakout running the other way.

a Double A Breakout confirms, marking A2
a Double V Breakout then confirms, marking V2
a candle CLOSES below that old A2
-> V2 becomes a DBO to DBO V level

The bullish case is the mirror: a Double V, then a Double A, then a close above the old V2, and
A2 becomes a DBO to DBO A level.

The cross break may land on the very same candle that confirmed the second Double Breakout, or on any candle after it. What it says is that the level which had just been established as the place price wanted to leave from has now been given up in the other direction, by a move built the same strict way.

The level is UPGRADED, not duplicated. A DBO to DBO A sits at exactly the price its Double A
Breakout already marked - it is the same level with more behind it - so the line already on the
chart changes its name and thickens rather than a second line being drawn on top of the first.


WHAT MAKES THIS DIFFERENT

1. Nothing is marked when it forms.

An A Level or a V Level on its own is never drawn. Two of them together are never drawn either.
Only the breakout puts something on the chart, which is why a whole session can pass with nothing new on it.

2. The pair rolls instead of resetting.

This is the piece that separates it from a plain two-level check. A staircase that keeps stepping
the same way keeps its pair alive, sliding one step at a time. A staircase that turns back on
itself starts again. Both cases are handled by the same rule.

3. The inner step is the level, not the outer one.

The outer step is what price had to close through to prove anything, so it has already been
consumed by the time the pattern completes. The inner step is the last one price never came back to, and that is what is drawn.

4. Breakout has priority over everything else.

Because reaching the outer step is itself the breakout, the order in which the two checks run
changes the result. Checking for new levels first would let a level that is really the start of
the next search interrupt the current one. Here the breakout is always resolved first.

5. The chain is a real state, not a coincidence.

A DBO to DBO level requires a full Double Breakout, then a full opposite Double Breakout, then
the first one's level being closed through. All three are tracked as one sequence, and any part
of it ageing out of the window cancels it.

6. The search itself can be watched.

The pair currently waiting for its breakout can be drawn, so the staircase can be seen sliding
before anything confirms. It is the working state, not a signal, and it is off by default.


READING THE CHART

Green line, "DBO A" Double A Breakout, label below
Red line, "DBO V" Double V Breakout, label above
Thick green, "DBO to DBO A" the bullish chain completed
Thick red, "DBO to DBO V" the bearish chain completed

Every line starts at the candle the level was read from and runs to the right, so the distance
from its origin to price shows how long it has been standing.

Labels are parked clear of that origin candle rather than on the level itself - under its low on a
bullish level, over its high on a bearish one. The level price is a candle CLOSE, so it sits
inside the candle, and a label placed there would be buried in the price action.

A chain level is always drawn one step thicker than a plain one. That is the only styling
difference, because it is the same kind of level, reached by a longer road.

With the working pair switched on, dotted lines labelled A1, A2, V1 and V2 show what is currently being tracked. A1 and A2 are the descending pair waiting for a close above A1; V1 and V2 are the ascending pair waiting for a close below V1. Watch A2 slide down as the staircase extends. If only A1 or only V1 is drawn, the search has one step and is waiting for its second.

Only the most recent few levels are drawn, so the chart stays readable. Older ones are still
counted in the corner table, which reports Double Breakout and DBO to DBO levels split into bull and bear. If the table reads higher than what you can see, the display limit is doing its job.


SETTINGS

Double Breakout
- Scan Length: how far back the search reaches. A pair that has been waiting longer than this is
abandoned, and a confirmed level is dropped once the candle it came from is older than this. It
also bounds how long a chain can stay open.
- Max Levels Shown: how many of the most recent levels are drawn. Switching a type off frees its slots for the others.

Level Types
- A switch for each of the four: Double A Breakout, Double V Breakout, DBO to DBO A, DBO to DBO V.
- Show Working Pair: draws the pair currently waiting for its breakout.

Level Style
- Bullish, bearish and working pair colours, line width, and whether levels extend to the right
edge. With extending off, a level stops at the candle that confirmed it.

Labels
- Show Labels, Label Size, and Label Distance from Candle as a percentage of ATR(14), so the gap scales with whatever instrument and timeframe you are on. The distance is measured from the origin candle's high or low, not from the level.

Summary Table

- Show, position and size of the corner table.


ALERTS

Four alert conditions:

Double A Breakout a descending pair was run out to the upside
Double V Breakout an ascending pair was run out to the downside
DBO to DBO A a bullish chain completed
DBO to DBO V a bearish chain completed

Each message carries the event, the symbol, the timeframe and the closing price. The same
messages are also sent through the alert function, so the "Any alert() function call" alert type
can deliver all four through a single alert.

Every alert is evaluated only after a candle has fully closed.


REPAINTING

This script does not repaint.

- The whole engine runs once per closed candle. Price moving inside an open candle cannot create, change or remove a level, and cannot make a signal appear and then disappear.
- Both building blocks need a candle AFTER them to exist at all. An A Level is only an A Level
once the red candle behind it has closed, so nothing is ever read from a candle still forming.
- Levels are built forward, one candle at a time, in the same order they would have been built live. A line that has been drawn never moves. The only thing that can change about it is its
name and thickness, when a later chain upgrades it, and that is a record of what price did
afterwards rather than a revision of what it did before.
- Nothing is read from a higher timeframe, so there is no higher timeframe lookahead to get
wrong.

When you create an alert, TradingView may show a caution banner saying the indicator can repaint. That banner appears automatically for any script that uses the built in bar state variables, no matter how they are used, because the platform cannot check the intent behind them. This script uses one of them for the opposite purpose: it is what restricts the entire engine to bar close.Choosing "Once Per Bar Close" when creating the alert is still recommended.


NOTES AND LIMITATIONS

- Levels are deliberately infrequent. Two same-side reversals have to line up and then be run
through by a close, and a DBO to DBO level needs that to happen twice in opposite directions.
Long stretches with nothing new are normal.
- Scan Length is not only cosmetic here. It decides when a waiting pair is abandoned and when a chain expires, so changing it changes what is found, not just what is drawn. Max Levels Shown
is the cosmetic one.
- A doji takes no part. An A Level or V Level needs one candle of each colour, so a pair
containing a doji is not one.
- DBO to DBO upgrades the existing level in place. The count of plain Double Breakouts therefore goes down by one each time a chain completes, because that level has become
something else.
- An internal cap of 120 stored levels keeps the drawing count inside TradingView's limits. On a
very long history the oldest are dropped.
- Detection is purely structural. It reports where these sequences occurred and nothing more. It
does not rank levels by quality, measure what happened next, or produce entries, targets or
stops.


HOW TO USE IT

A Double Breakout level marks the last place the other side stepped in before price left the
area. Traders commonly watch these for:

- A reaction on the first return, since price has not been back to that step since the breakout
- Direction from the side, where a bullish level below price and a bearish level above it frame
the range price is currently working in
- Confirmation against a higher timeframe read, where a level that agrees with the larger picture carries more weight than one that fights it

A DBO to DBO level is the same level after the market has argued about it twice. The road to it
was longer, and it sits where a completed move in one direction was undone by a completed move in the other.

The working pair is worth turning on while learning the tool. Watching A2 slide down step by step makes it obvious what the breakout is waiting for, and where it would have to close for anything to be drawn.

These are reference areas, not entry signals on their own. Use them alongside your own support
and resistance mapping, your own entry method and proper risk management.


DISCLAIMER

This indicator is a pattern detection tool. It is not financial advice and it makes no claim
about profitability. Trading involves risk. Always apply your own analysis and risk management.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน