OPEN-SOURCE SCRIPT

Order Block (OB) Statistics: Real Win Rate vs Random Levels

1 183
On real price data, a 54% win rate can be worse than random, and a 46% win
rate can be better. Whether a level "works" depends on the number it is
compared with. That comparison number is called the baseline, and for levels
on a chart it is almost never exactly 50%.

An order-block arrow is therefore not evidence of an edge. The practical
question is simple: does price behave differently after touching an order
block than after touching a similar level with no order-block event behind
it?

This script performs that comparison. It does not generate buy or sell
signals; it measures the entry logic that such signals rely on.

The measurements behind this publication were made on a forex pair
(EURUSD), a crypto pair (BTCUSDT) and an equity index future (ES1!). The
script itself runs on any symbol and timeframe.

What to Use It For

Evaluating what already exists. Whatever tool draws your order
blocks, set this script's inputs to match the same rules. The panel then
shows how those zones performed against matched comparison levels. The
comparison levels are measured on the same chart, in the same direction,
with the same size and distance from price.

Evaluating something before you build it. Entry, exit, sizing and
filters are normally backtested together. Because of this, even a profitable
backtest may not show which part produced the result. This script isolates
the entry and asks one question: after price reaches the zone, does it
behave differently than after reaching a similar level where nothing
happened? If not, exit rules may change the size of wins and losses, but
they cannot add information that the entry does not have. You can learn that
before writing the full strategy.

Generalizing beyond order blocks. Supply and demand zones, breaker
blocks, support and resistance, session highs and lows, and other
level-based signals can be evaluated with the same test. The rule that
builds the level changes; the baseline problem does not.

Order blocks are widely taught and rarely measured.

快照
Order blocks on BTCUSDT 30m. Open zones extend to the right until price
reaches them. Once reached, they freeze and change to dotted lines, showing
how long each zone lasted. Triangles mark the break of structure - a close
beyond the most recent swing - that confirmed each zone as an order block.
The panel in the corner is the measurement. It scores every zone in the
selected date range - 1,854 of them here, not just the dozen visible -
against matched control levels.


The Result in Plain Language

The study contains 31 runs. They cover the three instruments named above,
timeframes, periods, barrier widths (target and stop distances) and
order-block definitions. No tested configuration showed a reliable
difference between real order blocks and their placebo levels, and no
configuration repeated such a difference on other instruments. A placebo
level is a matched comparison zone with no order-block event behind it.
The combined estimates were slightly below zero, but the uncertainty range
still included zero.

This does not prove that all order-block concepts fail. It only reports what
this definition, this measurement method and this sample showed - and did
not show. The value of the script is the method. The sections below explain
each term before it is used and show how to apply the same measurement to
your own rules.


Terms Used in the Panel

Hit rate. The percentage of counted outcomes in which the target was
reached before the stop. This is the raw result that a simple backtest would
usually report.

Placebo or control level. A comparison zone with no order-block
event, but matched to the real zone by height, direction and distance from
price. It estimates the hit rate that price movement, general trend and
level placement produce on their own, without any order-block information.

Edge estimate: "real - placebo." The real-zone hit rate minus the
control-zone hit rate. A positive value means the real zones performed
better than the controls; a negative value means they performed worse.

Percentage point (pp). An absolute difference between percentages.
For example, 54% minus 50% equals +4 percentage points, not +4% relative
growth.

z score. The edge estimate divided by a measure of its statistical
noise (the standard error). It shows how large the observed difference is
compared with normal random variation. As a widely used threshold, an
absolute z score near 2 is treated as a first sign of a real effect. This
study also requires the result to repeat before drawing a conclusion.

95% confidence interval (95% CI). A range around the estimate that
shows how uncertain it is. When the range includes zero, the data do not
clearly show a positive or a negative difference.

Ambiguous outcome. A bar whose high and low contain both the target
and the stop. Open-high-low-close data cannot show which one price reached
first. The script counts such cases against the hit rate, which is the safe
choice.

Censored outcome. A zone that reaches neither barrier before the time
limit. It is reported separately and not counted in the hit rate.


Why 50% Is the Wrong Baseline

Any rule that enters when price reaches a level already has some hit rate
before any real signal is involved. That hit rate comes from how price moves
and drifts on its own. Intuition says that with equal target and stop
distances, price should reach each side half the time. On real price data
this is often not true, and the size of the difference varies by instrument,
direction and period.

Across the runs behind this publication, the baseline for levels with no
special meaning ranged from 47.3% to 52.3% overall, and from 43.3% to 54.6%
after splitting by direction. This is the source of the numbers at the top
of this description: a 54% long hit rate can be below its baseline, while a
46% short hit rate can be above its baseline.

The script measures both sides at once. For every confirmed order block, it
also places control zones of the same height, direction and distance from
price, at bars where no order-block event occurred. Real and control zones
are then measured in exactly the same way.

The "real - placebo" row is therefore the primary result. It subtracts the
part of the performance that the baseline alone explains. It is more
informative than the raw hit rate. The control does not remove every
possible difference, however; those limits are listed below.


What Counts as an Order Block

A swing high or swing low is confirmed a fixed number of bars after it
forms. A break of structure is a close beyond the most recent unbroken
swing. The break is tested on the closing price only, never inside a bar.
The order block is the source candle: the last candle before the break
that moved the other way. An upward break points back at the last down
candle; a downward break points back at the last up candle.

The close is used rather than the high or the low because a bar's extreme
has no known timing. OHLC data records that price reached a level during
the bar, not when, and every measurement here has to start from a defined
moment. A close supplies one. It also means a break that is reversed
before the bar ends does not count as a break.

The important question is: when does the zone become visible in real time?

An order block is not visible when its source candle forms. The candle
becomes a zone only after a later break of structure points back to it. Two
bars are therefore involved: the source bar on which the zone is drawn and
the confirmation bar on which the break closes.

Every measurement starts from the confirmation bar forward. Price that
reached the source candle before the zone became visible is not a trade and
is not counted. Because confirmation occurs at a close, the first touch test
is performed on the following bar. Control zones use the same one-bar delay
so the comparison stays fair.

快照
A single order block, zoomed in. The source candle is where the zone is
drawn. The triangle several bars later marks the close that confirmed the
break of structure - the first moment the zone existed for a user in real
time. The bars between the two were not tradeable, and nothing in that
interval is counted.


How the Measurement Works

A risk unit, or R, is selected in the settings as either average true range
(ATR) or zone height. It sets the scale of the measurement: for example, a
barrier size of 2R places both the target and the stop two selected risk
units from entry.

Average true range is the average size of a bar's full range over a set
number of bars, including any gap from the previous close - in effect, how
far price typically travels in one bar. Setting barriers in ATR rather than
in points means a 2R barrier is twice the recent typical bar range, so the
same setting means the same thing on a volatile instrument and a quiet one.

The ATR used for a zone's barriers is read once, at the bar where that
zone is created - the confirmation bar for a real zone, the placement
bar for a control zone - and stays fixed for that zone.

The near edge of a zone is the side facing price after the break: the top of
a bullish zone, the bottom of a bearish one. It is the side price has to come
back to.

When price returns to the near edge of a zone, the entry is recorded at that
bar's close. A target and a stop are placed the selected number of risk
units away, one in each direction. For a bullish zone the target is above
the entry and the stop below it; for a bearish zone, the reverse. The
script then records which barrier price reaches first, starting from the
next bar.

Entry is recorded at the close rather than at the zone edge for a specific
reason. A touch is triggered when price crosses the edge, not only when
price equals it, so the touching bar may cross the edge by an unknown
amount. Suppose the entry were recorded at the edge price while the
measurement started on the next bar. Then the measurement would begin after
price had already moved away from the assumed entry. The entry price and the
price from which the barriers are measured must be the same.

Sometimes a single bar contains both the target and the stop.
Open-high-low-close (OHLC) data alone cannot show which one price reached
first inside that bar. Such outcomes are marked ambiguous and counted
against the hit rate, which is the safe choice.

Zones that reach neither barrier inside the time limit are censored.
Censoring is the statistical term for an observation whose outcome was
never seen: the zone was still running when the limit expired, which is
known, and nothing more. Counting it as a win or a loss would mean
inventing the missing outcome, so it is dropped from the hit rate and
reported separately.

Ambiguous and censored counts are reported for real and control zones
separately. They cancel out of the difference only when both sides show them
at similar rates.

快照
One measurement from beginning to end: the confirming break, price
returning to the near edge, entry at that bar's close, and the barrier
that was reached first - here, the stop. On this instrument the aggregate
ran negative over the test window; the result did not replicate on the
other two instruments and is recorded as unresolved in the limitations
section. The panel reports what it measures.


Where the Method Comes From

None of the statistics here are new, and it is worth being clear about that.

A standard way to test a method is to apply it where the signal does not
exist, then check that no effect appears. In statistics this is called a
placebo test, and it is a common tool in causal inference - the field that
studies cause and effect. The placebo zones in this script apply that idea
to price bars instead of people.

The trading application is not new either. David Aronson's
Evidence-Based Technical Analysis (2006) argues that a trading rule
should be compared with random entry signals rather than with zero. His book
uses Monte Carlo permutation and White's Reality Check for this purpose.

The scoring rule - a target, a stop and a time limit, whichever is reached
first - is the triple-barrier method described by Marcos López de Prado.

What this script adds is not the method but its availability. The control is
created and scored automatically next to the real zones, on any chart and
any symbol. The baseline arrives together with the result, instead of
requiring a separate study that most people will never run.


How to Use It

1. Match the definition. Set the order-block inputs to reproduce the
rules used by the indicator, strategy or idea you want to evaluate. A
statistical result only applies to the definition that produced it.

2. Run the built-in validation first. Enable synthetic mode before
interpreting live-market results. Synthetic mode replaces price internally
with a random walk - artificial price data that moves randomly and contains
no real signal - whose correct answer is known. If the measurement does not
recover that answer, the market result should not be trusted.

3. Check the sample funnel. The funnel accounts for every break of
structure: how many found no source candle, fell below the displacement
filter (a minimum move size, set in the settings), had price already inside
the zone at confirmation, or became measurable zones. If the categories
do not add up to the break count, the panel reports the mismatch.

4. Check measurement quality. A barrier size of 1R often resolves
within a few bars. It may then only measure price noise right at the entry
rather than what happens afterward; the panel flags it as TOO TIGHT. Set the
time limit long enough to keep the number of censored zones small, and
compare the real and control ambiguous and censored rates.

5. Read the three core rows. "Hit rate" is the raw real-zone result
and sample size. "Placebo" is the matched baseline. "Real - placebo" is the
edge estimate. Read its size first, then its z score and confidence
interval. Do not treat a high raw hit rate as evidence of an edge unless it
also exceeds the matched baseline.

6. Look for repetition, not the best single result. Repeat the same
configuration on other instruments and independent periods. A result that
appears on only one chart can be random variation rather than a reusable
signal.


Results

The study contains 31 runs and 23 distinct estimates. They span three
instruments from three asset classes - BTCUSDT (crypto), EURUSD (FX) and
ES1! (an equity index future) - plus four timeframes, three time periods,
three barrier widths and eight definition variants.

In the table, Estimate means "real - placebo" in percentage points. A
negative estimate means the placebo levels performed better. The z score
compares that estimate with its statistical noise, and the 95% CI shows the
uncertainty range.

Pine Script®


Every pooled row combines the same three instruments: BTCUSDT, EURUSD and
ES1!. They are one crypto pair, one FX pair and one equity index future
sharing the same calendar window, chosen so that a result holding on all
three cannot come from the structure of a single market.

The decision rule was fixed before the runs: a single configuration had to
reach an absolute z score above 2 (|z| > 2) and then repeat on two other
instruments. One result crossed the single-run threshold: EURUSD 30m at
-4.9pp and z -2.69. It failed both repetitions. The same configuration
returned +0.1pp on BTCUSDT and +0.8pp on ES1!. Its two independent EURUSD
periods combined to -1.23pp at z -0.55, and the sign flipped between the
two periods.

No tested configuration met the full decision rule. The most precise
combined estimate was -1.73pp, and its confidence interval included zero.
The balanced pool - the same three instruments over the two periods that
share no data, before adding the third EURUSD year - gave -2.10pp at
z -1.91, the largest combined deviation in the study; its interval of
-4.3 to +0.1 also included zero, by a small margin. The study therefore
did not detect a reliable positive or negative order-block effect under
the tested conditions.

None of the tested refinements changed the conclusion. A displacement
filter that discarded 56% of breaks, body-only zones, the mitigation
requirement (the Require price outside setting: it discards a zone if price
was already inside it when the break of structure closed), and swing length
across a 3.3x range all moved the estimate by less than the measurement
noise.

Using 50% as the comparison point can create a false conclusion in either
direction.
Order blocks filtered to 2 ATR of displacement produced a
46.7% hit rate and z -1.83 against a 50% comparison, which could be
presented as evidence that the setup loses. Against the matched control, the
same runs produced -0.6pp at z -0.29. The apparent result came mostly from
the wrong baseline, not from the order blocks.

To reproduce the published figures: The script defaults match the
configuration used for these estimates. Set the date range to 2025-01-01
through 2026-08-01 for rows labelled 2025-26, or use the matching calendar
year for the other rows. Disable compact panel mode to display the funnel
counts. The three instruments are BTCUSDT, EURUSD and ES1!.

A final note on direction. The mean of all 23 estimates is -0.87pp,
while the same statistic on data built to contain no edge returned -0.44pp.
Fifteen estimates are negative, seven are positive and one is exactly zero.
The estimates share data, so this count is not a formal statistical test.
The data do not establish an exact zero effect, but they do limit how large
any real effect could be within this design and sample.


Validation

Driftless random-walk check. On a driftless random walk, an entry
with equal barriers reaches either side with equal probability. Synthetic
mode replaces price with such a walk, so the combined real and control hit
rates should stay close to 50%, within normal statistical variation.

Eight seeds were tested - starting values for the random generator, each
producing a different artificial price series. The combined real hit rate
was 49.83% and the combined control hit rate was 50.26%, both within 1.5
standard deviations of 50% - that is, well inside normal random variation.
Two of the eight individual runs fell outside the expected range, on
opposite sides of the test and in opposite directions. That pattern
matches ordinary random variation, not a systematic measurement error.

Resolution check. Combined across all eight seeds, the difference
statistic was -0.44pp even though the synthetic data contained no edge. This
shows the smallest difference the design can detect in practice: at this
sample size, differences smaller than about 1.2 percentage points cannot be
separated from measurement noise.

Drift stress test. The same validation was then repeated after adding
drift, while the data was still built to contain no signal edge.

快照
Synthetic mode with drift, where no edge exists by construction. Against the
50% comparison the long side reads 59.6% at z +5.33 and the short side 38.8%
at z -5.89. Both look statistically significant, and both are false signals
created by the wrong baseline. Against the matched control the same two sides
read -0.59 and -0.16 percentage points, at z -0.27 and -0.07, and the
aggregate difference is 0.0%. Synthetic mode replaces price internally, so
the chart behind the panel does not show the tested data.


Settings

Order-block definition. Swing length sets how many bars on each side
are required to confirm a swing point. Search depth sets how far back from
the break the script looks for the source candle. Zone bounds selects either
the full candle range or the candle body. Minimum displacement can require
the move from the source candle to the break to span a selected number of
ATR. Require price outside excludes zones that price had already traded into
by the time of confirmation.

Measurement. Risk unit selects ATR or zone height. Barrier size sets
the target and stop distance in risk units. Time limit removes zones that
have not reached either barrier in time (censoring). Entry price offers the
bar close or the zone edge; the zone-edge option is included for comparison
but is labelled biased. Minimum zone height and the overlap filter determine
which zones enter the sample, while the overlap window sets how far back the
filter compares.

Sample. The range uses explicit year, month and day fields rather
than a date picker. The built-in picker can silently snap to the loaded data
and change the dates, which would make a published result hard to reproduce.

Placebo control. Sets the number of control zones generated for each
real zone and the bar offset used to place them.

Validation. Controls synthetic mode, seed, step size and drift per
bar.

Display. Controls compact panel mode, zone drawing and break markers.


Limitations

The control does not match every feature. It matches zone size,
direction and distance from price, but it does not match the fact that a
strong move in that direction has just happened. In trending markets this
gap matters for direction: control long and short hit rates differed by as
much as 10.9 percentage points. Treat long/short splits as unreliable in
trends. The combined result is also affected, to a degree this study does
not measure.

One instrument remains unresolved. EURUSD 30m returned -4.9pp at
z -2.69. The result failed repetition on both other instruments, and its two
independent EURUSD periods combined to -1.23pp at z -0.55 with opposite
signs. The available history cannot fully separate a real
instrument-specific effect from a random outlier.

Single runs are not precise enough to support the conclusion on their
own.
An order block requires a break of structure, so observations are
rarer than for many gap-based patterns. A single instrument-timeframe run
can only detect differences of about 3 percentage points or larger. The
combined estimates therefore carry more weight than any single run.

Loaded chart history limits the sample. The number of bars loaded by
the chart, not only the selected calendar dates, determines how much data a
run can use. The 5-minute cell reaches only a few months, so the effects of
its period and its timeframe cannot be separated.

Historical measurement is not a forecast. The script reports what
happened under the specified rules and sample. Past behavior of a level does
not guarantee or predict future behavior.


Disclaimer

This script and its description are provided for educational and research
purposes only. They do not constitute financial, investment, trading or
other professional advice, and they do not recommend buying, selling or
holding any asset. Historical and simulated results do not guarantee future
performance. Trading involves risk, including the possible loss of capital.
You are solely responsible for your trading and investment decisions and
should conduct your own research and, where appropriate, consult a
qualified financial professional.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。