OPEN-SOURCE SCRIPT
iNaka Market Structure

iNaka Market Structure marks Break of Structure (BOS), Change of Character (CHoCH) and liquidity
sweeps from confirmed swing pivots, and scores every break from 0 to 100 so a decisive break and a
marginal one are distinguishable without eyeballing the candles.
It is one self-contained engine, not a combination of existing indicators. ATR appears only as a unit
of measurement, so that a threshold means the same thing on gold as on a currency pair; it is never
used as a signal.
WHAT IT DRAWS
- A dashed line at the active Ref High and Ref Low: the most recent confirmed swing high and swing low
that price has not yet broken. Dotted instead of dashed means the level is an equal-high/equal-low
cluster.
- BOS or CHoCH labels carrying the 0-100 strength score, with a line drawn back to the pivot that was
broken.
- "sweep" marks where price ran a level intrabar and closed back inside it.
- A status panel showing the current bias, the leg count, and both active levels.
HOW IT WORKS
1. Pivots. A pivot high is a bar whose high exceeds the Pivot Left bars before it and the Pivot Right
bars after it; a pivot low is the mirror. Two resolutions run in parallel on the same bars, Major
(default 15/15) and Minor (default 5/5), and you choose which one drives the labels, the bar
colouring and the alerts.
2. Reference levels. The most recent confirmed pivot on each side becomes a reference level. At most
one is live per side: one above price, one below. After a break, that side has no level at all
until the next pivot confirms - and because a pivot is only confirmed Pivot Right bars after it
prints, the level that replaces it is always at least that old.
3. Equal highs and equal lows. If a new pivot lands within Equal-Level Tolerance of the live reference,
it is treated as the same level being retested rather than a new one. The original level and its bar
index are kept and the level is flagged as a cluster. A double or triple top is therefore one level
tested three times, not three separate levels drifting down toward price.
4. Sweeps. If price trades through a live level but closes back inside it, that is reported as a sweep,
not a break: liquidity was taken and structure held. Each level reports its sweep once, so a level
poked twenty times inside a range produces one mark rather than twenty.
5. Breaks. A close through the level consumes it. If the prevailing bias already pointed that way, the
break is a BOS (continuation of the current leg). If it pointed the other way, it is a CHoCH, the
first break of a new leg. Bias starts undefined, so the first reported break on a chart is always a
BOS rather than a change of character with nothing to change from.
6. Break strength, 0 to 100, is the sum of four terms:
- up to 40 for displacement: how far beyond the level the bar closed, measured in ATR, saturating
at 1 ATR
- up to 25 for the leg count: how many consecutive breaks the current direction has produced,
saturating at 3
- 20 if the break follows a sweep on its own side inside the Sweep Arm window, i.e. a break that
first ran the stops resting behind it
- 15 if the level broken was an equal-high/low cluster, on the reasoning that repeated tests leave
more resting orders behind a level
WHAT IS DIFFERENT ABOUT IT
These are the specific design choices the engine makes, and the reasons it exists:
- Breaking and reporting are separate decisions. A close through a level always consumes it, so a
level can never sit stranded below price and then fire a stale break dozens of bars later. The
filters decide whether that break is reported at all: the bit, the label, the alert and the bias
update. The bias therefore advances only on reported breaks, so a CHoCH is always measured against the last bias you actually saw drawn. The leg count
deliberately does not: it advances on every break, because gating it would let one filtered break
starve every later break's score.
- Every break carries a composite 0-100 score built from four separately weighted, individually
explained terms - displacement, leg count, a side-matched sweep, and whether the broken level was a
cluster - and Min Break Strength filters on that score. The score is a ranking of breaks against
each other, not a probability.
- Equal levels cluster rather than replace. A near-equal pivot keeps the older level instead of
overwriting it, so a level that has been tested repeatedly stays anchored where the market actually
respected it.
- Two resolutions are computed in parallel on every bar, Major and Minor, with independent pivot
lengths and independent state. You choose which one reports; both stay live.
- Sweeps are one-shot per level. A sweep is treated as an event, not as a condition that re-reports on
every touch for as long as price hovers under the level.
SETTINGS
Structure
- Structure Resolution: which resolution is reported, Major or Minor. Both are always computed.
- Major Pivot Left / Right (15 / 15) and Minor Pivot Left / Right (5 / 5). Pivot Right is also the
confirmation lag: a pivot is only known that many bars after it prints.
Break Rules
- Equal-Level Tolerance (ATR), default 0.10. How close a new pivot must be to count as an equal
high/low. 0 disables clustering.
- Break Displacement (ATR), default 0. How far beyond the level the close must be for the break to be
reported. 0 reports every close-through.
- Displacement ATR Length, default 14. Used by both the displacement gate and the tolerance.
- Sweep Arm (bars), default 3. How long after a sweep a same-side break still earns the sweep bonus.
0 disables the bonus.
- Min Break Strength, default 0. Breaks scoring below this are not labelled or alerted.
Display
- Toggles for the reference levels, break marks, sweep marks, the score on labels, bar colouring by
bias, and the status panel; how many marks to keep on the chart; and the three colours.
HOW TO USE IT
- Start at defaults on the timeframe you actually trade. Major answers "what is the structural
direction"; Minor answers "what is happening inside the current leg".
- Treat a CHoCH as the first evidence that a leg has ended and a BOS as evidence that it continues.
The leg count in the panel tells you how extended the current sequence already is - note it counts
every break, including ones a filter hid, so it can move with no new label on screen.
- If the chart is too busy, raise Break Displacement or Min Break Strength rather than lengthening the
pivots. Longer pivots delay every level; the filters only hide the marginal breaks.
- A sweep followed by a same-side break is the sequence the strength score rewards most: the level was
defended, the stops behind it were taken, and then it broke anyway.
LIMITATIONS, WHICH YOU SHOULD READ BEFORE USING IT
- Pivots confirm Pivot Right bars after they print. A level therefore becomes active that many bars
late, and a break occurring inside that window is not seen. That lag is exactly what makes the engine
non-repainting on closed bars; it is inherent to confirmed pivots and no setting removes it.
- Within a forming bar, levels and marks can appear and disappear as the bar's high, low and close
move. Set every alert to "Once Per Bar Close".
- Reference levels ratchet. A newly confirmed pivot replaces the live one even when it sits lower for a
Ref High, because the rule is "most recent confirmed pivot", not "highest untouched pivot".
- The strength weights are a starting calibration chosen so the score stays interpretable. They are not
an optimised or validated result. Use the score to rank breaks against each other, not as a
probability of anything.
- Only the most recent marks are kept on the chart (default 60 of each kind). Scroll far enough back
and the older BOS, CHoCH and sweep marks have been deleted, and the two reference lines, which run from
their pivot to the right edge, leave the frame once you scroll back past their pivot. A blank
history is the drawing budget, not a fault.
- Break labels are placed at the midpoint of the line drawn back to the broken pivot, not on the break
bar itself, so on a long line the label sits well to the left of where the break happened.
- This is an analysis tool. It does not generate entries or exits, does not size or manage a position,
and makes no claim about profitability.
ALERTS
Six conditions: Bullish BOS, Bearish BOS, Bullish CHoCH, Bearish CHoCH, Bullish sweep, Bearish sweep.
All fire on the selected resolution. Set them to "Once Per Bar Close".
Published open-source under the Mozilla Public License 2.0.
```
**Conditional addition — only if you take the Minor fallback in chart-plan step 5.** Publishing a
chart on non-default settings without disclosing them is the violation-1 family, which binds every
visibility type. Add this line immediately above `Published open-source under the Mozilla Public
License 2.0.`:
```
The chart shown uses Structure Resolution = Minor. All other settings are at their defaults.
sweeps from confirmed swing pivots, and scores every break from 0 to 100 so a decisive break and a
marginal one are distinguishable without eyeballing the candles.
It is one self-contained engine, not a combination of existing indicators. ATR appears only as a unit
of measurement, so that a threshold means the same thing on gold as on a currency pair; it is never
used as a signal.
WHAT IT DRAWS
- A dashed line at the active Ref High and Ref Low: the most recent confirmed swing high and swing low
that price has not yet broken. Dotted instead of dashed means the level is an equal-high/equal-low
cluster.
- BOS or CHoCH labels carrying the 0-100 strength score, with a line drawn back to the pivot that was
broken.
- "sweep" marks where price ran a level intrabar and closed back inside it.
- A status panel showing the current bias, the leg count, and both active levels.
HOW IT WORKS
1. Pivots. A pivot high is a bar whose high exceeds the Pivot Left bars before it and the Pivot Right
bars after it; a pivot low is the mirror. Two resolutions run in parallel on the same bars, Major
(default 15/15) and Minor (default 5/5), and you choose which one drives the labels, the bar
colouring and the alerts.
2. Reference levels. The most recent confirmed pivot on each side becomes a reference level. At most
one is live per side: one above price, one below. After a break, that side has no level at all
until the next pivot confirms - and because a pivot is only confirmed Pivot Right bars after it
prints, the level that replaces it is always at least that old.
3. Equal highs and equal lows. If a new pivot lands within Equal-Level Tolerance of the live reference,
it is treated as the same level being retested rather than a new one. The original level and its bar
index are kept and the level is flagged as a cluster. A double or triple top is therefore one level
tested three times, not three separate levels drifting down toward price.
4. Sweeps. If price trades through a live level but closes back inside it, that is reported as a sweep,
not a break: liquidity was taken and structure held. Each level reports its sweep once, so a level
poked twenty times inside a range produces one mark rather than twenty.
5. Breaks. A close through the level consumes it. If the prevailing bias already pointed that way, the
break is a BOS (continuation of the current leg). If it pointed the other way, it is a CHoCH, the
first break of a new leg. Bias starts undefined, so the first reported break on a chart is always a
BOS rather than a change of character with nothing to change from.
6. Break strength, 0 to 100, is the sum of four terms:
- up to 40 for displacement: how far beyond the level the bar closed, measured in ATR, saturating
at 1 ATR
- up to 25 for the leg count: how many consecutive breaks the current direction has produced,
saturating at 3
- 20 if the break follows a sweep on its own side inside the Sweep Arm window, i.e. a break that
first ran the stops resting behind it
- 15 if the level broken was an equal-high/low cluster, on the reasoning that repeated tests leave
more resting orders behind a level
WHAT IS DIFFERENT ABOUT IT
These are the specific design choices the engine makes, and the reasons it exists:
- Breaking and reporting are separate decisions. A close through a level always consumes it, so a
level can never sit stranded below price and then fire a stale break dozens of bars later. The
filters decide whether that break is reported at all: the bit, the label, the alert and the bias
update. The bias therefore advances only on reported breaks, so a CHoCH is always measured against the last bias you actually saw drawn. The leg count
deliberately does not: it advances on every break, because gating it would let one filtered break
starve every later break's score.
- Every break carries a composite 0-100 score built from four separately weighted, individually
explained terms - displacement, leg count, a side-matched sweep, and whether the broken level was a
cluster - and Min Break Strength filters on that score. The score is a ranking of breaks against
each other, not a probability.
- Equal levels cluster rather than replace. A near-equal pivot keeps the older level instead of
overwriting it, so a level that has been tested repeatedly stays anchored where the market actually
respected it.
- Two resolutions are computed in parallel on every bar, Major and Minor, with independent pivot
lengths and independent state. You choose which one reports; both stay live.
- Sweeps are one-shot per level. A sweep is treated as an event, not as a condition that re-reports on
every touch for as long as price hovers under the level.
SETTINGS
Structure
- Structure Resolution: which resolution is reported, Major or Minor. Both are always computed.
- Major Pivot Left / Right (15 / 15) and Minor Pivot Left / Right (5 / 5). Pivot Right is also the
confirmation lag: a pivot is only known that many bars after it prints.
Break Rules
- Equal-Level Tolerance (ATR), default 0.10. How close a new pivot must be to count as an equal
high/low. 0 disables clustering.
- Break Displacement (ATR), default 0. How far beyond the level the close must be for the break to be
reported. 0 reports every close-through.
- Displacement ATR Length, default 14. Used by both the displacement gate and the tolerance.
- Sweep Arm (bars), default 3. How long after a sweep a same-side break still earns the sweep bonus.
0 disables the bonus.
- Min Break Strength, default 0. Breaks scoring below this are not labelled or alerted.
Display
- Toggles for the reference levels, break marks, sweep marks, the score on labels, bar colouring by
bias, and the status panel; how many marks to keep on the chart; and the three colours.
HOW TO USE IT
- Start at defaults on the timeframe you actually trade. Major answers "what is the structural
direction"; Minor answers "what is happening inside the current leg".
- Treat a CHoCH as the first evidence that a leg has ended and a BOS as evidence that it continues.
The leg count in the panel tells you how extended the current sequence already is - note it counts
every break, including ones a filter hid, so it can move with no new label on screen.
- If the chart is too busy, raise Break Displacement or Min Break Strength rather than lengthening the
pivots. Longer pivots delay every level; the filters only hide the marginal breaks.
- A sweep followed by a same-side break is the sequence the strength score rewards most: the level was
defended, the stops behind it were taken, and then it broke anyway.
LIMITATIONS, WHICH YOU SHOULD READ BEFORE USING IT
- Pivots confirm Pivot Right bars after they print. A level therefore becomes active that many bars
late, and a break occurring inside that window is not seen. That lag is exactly what makes the engine
non-repainting on closed bars; it is inherent to confirmed pivots and no setting removes it.
- Within a forming bar, levels and marks can appear and disappear as the bar's high, low and close
move. Set every alert to "Once Per Bar Close".
- Reference levels ratchet. A newly confirmed pivot replaces the live one even when it sits lower for a
Ref High, because the rule is "most recent confirmed pivot", not "highest untouched pivot".
- The strength weights are a starting calibration chosen so the score stays interpretable. They are not
an optimised or validated result. Use the score to rank breaks against each other, not as a
probability of anything.
- Only the most recent marks are kept on the chart (default 60 of each kind). Scroll far enough back
and the older BOS, CHoCH and sweep marks have been deleted, and the two reference lines, which run from
their pivot to the right edge, leave the frame once you scroll back past their pivot. A blank
history is the drawing budget, not a fault.
- Break labels are placed at the midpoint of the line drawn back to the broken pivot, not on the break
bar itself, so on a long line the label sits well to the left of where the break happened.
- This is an analysis tool. It does not generate entries or exits, does not size or manage a position,
and makes no claim about profitability.
ALERTS
Six conditions: Bullish BOS, Bearish BOS, Bullish CHoCH, Bearish CHoCH, Bullish sweep, Bearish sweep.
All fire on the selected resolution. Set them to "Once Per Bar Close".
Published open-source under the Mozilla Public License 2.0.
```
**Conditional addition — only if you take the Minor fallback in chart-plan step 5.** Publishing a
chart on non-default settings without disclosing them is the violation-1 family, which binds every
visibility type. Add this line immediately above `Published open-source under the Mozilla Public
License 2.0.`:
```
The chart shown uses Structure Resolution = Minor. All other settings are at their defaults.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。