OPEN-SOURCE SCRIPT

AMD Structure Map [AxeAlgo]

3 609
AMD Structure Map [AxeAlgo]
============================================
------------------------------------------------------------
WHAT THIS SCRIPT DOES
------------------------------------------------------------
AMD Structure Map automatically detects the Accumulation → Manipulation →
Distribution cycle on any chart, in real time, and draws each phase as its
own labeled zone directly on the candles — so the market's own three-act
structure is visible as it forms, instead of something you have to
eyeball yourself after the fact.

This is a pattern-recognition and structure-labeling tool. It identifies
and visualizes market structure per the AMD model. It does not predict
future price direction, it does not generate buy or sell signals, and
nothing it draws should be treated as a trading recommendation.

------------------------------------------------------------
BACKGROUND — WHAT "AMD" MEANS
------------------------------------------------------------
AMD is a way of reading price action as three sequential acts:

Accumulation is a period where price contracts into a range while orders
build on both sides of the market. Manipulation is a deliberate-looking
move beyond that range — far enough, and on enough volume, to run the
stop-losses and breakout orders sitting just outside it — that then fails
and closes back inside. Distribution is the real, sustained move that
follows, expanding in the opposite direction of that failed move.

The core idea is that the Manipulation phase exists to create liquidity:
a move beyond an obvious range draws in breakout traders and triggers
stops on the other side, providing the volume needed for the real
directional move that follows. Whether or not you subscribe to that
interpretation, the three-part sequence — range, false break, real break
— is a recurring, observable structure across most liquid markets and
timeframes, and this script exists to detect it mechanically and
consistently rather than by eye.

------------------------------------------------------------
HOW EACH PHASE IS DETECTED
------------------------------------------------------------
ACCUMULATION is flagged by genuine volatility contraction: a fast-length
ATR reading meaningfully below its own slow-length ATR baseline, averaged
over a short recent window rather than judged off a single bar, combined
with a minimum range width relative to current volatility. This rules out
both a lone quiet tick being mistaken for real compression and micro-noise
ranges being mistaken for a real base. Once contraction is confirmed, the
zone locks to the highest high and lowest low of the seed window and does
not move afterward.

MANIPULATION is a liquidity sweep: a wick that pierces beyond the
Accumulation range by a minimum distance, on volume above this specific
cycle's own frozen baseline (measured from its own seed window, not a
constantly-rolling average that would otherwise get distorted by the
sweep's own volume spike), that closes back inside the range within a
short window of bars. It does not have to reverse on the exact same bar
it pierced — it is given a handful of bars to do so, since real liquidity
sweeps do not always resolve instantly. The moment a sweep confirms, the
script labels the zone with an Expected Direction: opposite the side that
was swept, since that is what the AMD model itself defines Distribution to
be. If price later sweeps the OPPOSITE side too, before the range
resolves, that second sweep supersedes the first and the call flips —
capped at one such re-arm, since a range swept a third time no longer
looks like a clean setup.

DISTRIBUTION is a confirmed break — by distance and by volume, both judged
against that same frozen baseline — in the direction the Manipulation
phase called. Only at that point is the cycle logged as complete. A break
in the SAME direction as the earlier sweep is logged separately and
honestly as "Manipulation Failed," since the expected reversal did not
occur — the script does not force an incomplete or contradictory sequence
into the AMD narrative just because a Manipulation event happened
somewhere in the range's history.

------------------------------------------------------------
ON THE EXPECTED DIRECTION LABEL
------------------------------------------------------------
The "Expected Direction" shown on the Manipulation zone is a direct
restatement of the AMD model's own definition, not an independent
forecast: Distribution is, by definition, the move opposite the side that
got swept. It carries no probability estimate, is not back-tested, and is
not a trade instruction. It is confirmed or denied by the same real
price-and-volume break logic used everywhere else in the script — nothing
is assumed true until price actually does it.

------------------------------------------------------------
WHAT YOU SEE ON THE CHART
------------------------------------------------------------
Each phase is drawn as its own colored zone box with a label. The
Accumulation zone appears the moment contraction confirms. The
Manipulation zone appears the moment a sweep confirms, labeled with the
Expected Direction. The Distribution zone appears ONLY once the break
genuinely confirms in that expected direction — it is sized to the
Accumulation range's own width rather than to whatever the breakout bar's
own volatility happened to produce, then grows to track the real move for
a limited window before freezing in place, so it always reads as a
proportionate rectangle rather than an arbitrary spike or a box that
keeps expanding indefinitely.

A cycle that does not complete — a Manipulation that failed to lead to a
real Distribution break, or a breakout with no Manipulation ever detected
beforehand — is marked with a single small flag rather than a full zone
box, since nothing pattern-like actually happened there. A small signal
also marks the exact first candle a genuine Distribution phase begins on.

An optional session-window highlight is available for traders who want to
see which cycles are forming inside a specific trading session.

------------------------------------------------------------
DASHBOARD
------------------------------------------------------------
A compact corner table shows the current phase and its status, the
current Expected Direction, an optional higher-timeframe bias reading
(a simple moving-average slope check on a timeframe you choose, shown
purely as background context and never used to filter or alter
detection), and a running Follow-Through Rate.

The Follow-Through Rate is a historical tally, going back to when the
chart loaded, of how often this chart's own past Manipulation calls
actually went on to confirm into a real Distribution break versus failing
or the range simply expiring. It is not a win rate, not the result of a
back-tested strategy, and not a claim about the cycle currently forming.
The percentage is intentionally hidden until a minimum number of cycles
have been observed, so a small handful of outcomes is never presented as
a statistically meaningful rate.

------------------------------------------------------------
INPUTS
------------------------------------------------------------
A single Detection Sensitivity dial (Loose / Normal / Strict) governs
every underlying threshold at once — the seed window length, the required
depth of volatility contraction, the sweep depth and volume requirements,
and the breakout distance and volume requirements. Loose finds more
cycles at looser quality; Strict finds fewer, higher-conviction cycles
only.

Beyond that, every visual element can be toggled or recolored
independently: the zone boxes, the phase labels, the Expected Direction
label, the Distribution start signal, the Follow-Through Rate row, the
higher-timeframe bias row, the session highlight, and the on-chart legend.
A "completed cycles only" mode is also available, which hides everything
while a cycle is still forming and only draws it — retroactively, all at
once — if and when it actually completes the full sequence.

------------------------------------------------------------
CALCULATION AND REPAINT BEHAVIOR
------------------------------------------------------------
All detection logic runs exclusively on confirmed, closed bars. Nothing is
decided from an intrabar wick on the currently forming candle. A sweep
candidate's return window is evaluated bar by bar as it actually happens,
never by looking ahead. A confirmed Manipulation call can be superseded
later within the same range by the one-time re-arm described above, but
only by an equally real, fully confirmed opposite-side sweep — never
speculatively, and never by revising a call that has already led to a
resolved outcome. Once a range resolves, or a zone's phase has finished,
its boundaries are not redrawn or repainted. Higher-timeframe data is
requested with lookahead explicitly disabled, so historical bars never
change; only the still-forming higher-timeframe candle can naturally
update until it itself closes, which is standard behavior for any
multi-timeframe context reading and is not repainting in the sense of
historical values changing after the fact.

------------------------------------------------------------
LIMITATIONS
------------------------------------------------------------
This script is a structure-labeling tool, not a trading system. It has no
concept of risk management, position sizing, or trade execution, and it
does not account for spread, slippage, commissions, or liquidity
conditions specific to any individual broker or exchange. Detection
quality depends heavily on the instrument, timeframe, and chosen
sensitivity setting — a setting well suited to one market or timeframe may
under- or over-detect on another, and some manual tuning of the
sensitivity dial is expected. Past detected cycles, and the Follow-Through
Rate built from them, describe what has already happened on this specific
chart and are not a guarantee of how future cycles on the same chart, or
on any other chart, will behave.

------------------------------------------------------------
DISCLAIMER
------------------------------------------------------------
This script detects and labels historical and current market structure
per the AMD model only. Nothing it displays is a probability of future
price direction, a guarantee, or a buy or sell instruction — a
Manipulation event describes a liquidity sweep that has already happened,
not a prediction of what comes next, and a Distribution zone is only ever
drawn once the corresponding break has already confirmed. The Expected
Direction label is a restatement of the pattern's own definition, not a
forecast. The Follow-Through Rate is a tally of what has already happened
to this chart's own past Manipulation calls, typically a modest sample
size, and should not be read as a win rate or as investment advice.
Trading involves substantial risk of loss and is not suitable for every
investor. Nothing in this script or its description constitutes financial,
investment, or trading advice, and past structure detected by this
script is not indicative of future results. Use at your own discretion
and risk.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.