Quant from Scratch by QuantWright

Testing Popular Ideas · Lesson 14

SMC: order blocks

The last candle before a strong move, and the saying that the price comes back to it: which candle, how strong a move, how often the price does come back when there is nothing to find, and the 24 versions of a rule built on it.

Know the basics? Read the lesson notes

The last candle before the move

Several lessons cover ideas that traders group under "smart money concepts" (SMC): fair value gaps, order blocks, liquidity sweeps, market structure. They spread through free video lectures and are now taught by many educators, each with their own definitions. We code one common reading, show the switches where readings differ, and test that. It is our reading, not anyone's official method.

Take candles in a row (a candle holds the open, high, low and close of one stretch of time; here, five minutes). When the price suddenly moves hard one way, the last candle that went the other way just before the move is called an order block. A popular saying is that the price tends to come back to it later.

The prices in this lesson are simulated: made up by a computer, not a real market. These markets were built so that past prices say nothing about which way the next move goes; the counts here show what order blocks and rules built on them do when there is nothing to find. They cannot show whether the idea works in a real market.

Five made-up candles, then a move up

Each candle: a line from its low to its high, a box from its open to its close, empty if it closed higher, filled if it closed lower.

Read as the last candle that closed lower before the move up, which one is the order block?

A closed lower and has the lowest low, but B closed lower after it. Another common reading picks the candle with the lowest low; a later card has that switch.
B is the last candle that closed lower (a filled box) before the move. Its range, now shaded, is the order block.
C closed higher (an empty box), so it didn't go the other way. B is the last one that did.

What counts as a strong move?

Traders call the strong move displacement, and define it in several ways. Three common ones: one candle whose body (its box, from open to close) is at least twice the average body of the 20 candles before it; at least three times; or a move so fast that the first and third of three candles in a row don't overlap, leaving a gap (the Fair value gaps lesson). The order block is looked for among the five candles before the move. The chart is one simulated day, 09:30 to 16:00. Try all three.

Every order block of one day, by displacement (simulated)

Each order block: its range, outlined from its candle to 16:00, numbered at its candle. Orange: before a move up. Grey: before a move down.

Displacement
Order blocks this day–
1,000 markets–

This day has 4, 2 and 4 order blocks. Across 1,000 simulated markets: 6.8, 1.9 and 9.0 a day. Each definition finds a different set.

Which candle, and which part of it

An order block marks a zone: the price range the price is said to come back to. Read from the wicks (the thin line), it is the candle's whole range, low to high; read from the body, only its box. Which candle is a choice too: the last one that went the other way, or the one with the lowest low of the five before the move. Below: this day's first move up that left a gap, at 10:45. Each bar is one candle, named by the time it starts. Try both switches.

One move, four zones (simulated)

Ring: the chosen candle. Shaded: its zone.

Candle
Zone
Candle–
Zone–

The last candle that closed lower is the 10:30 bar: zone 106.10 to 106.16 from the wicks, 106.11 to 106.16 from the body. The lowest low is the 10:20 bar, which closed higher: 106.00 to 106.17, or 106.06 to 106.15. One move, four zones, from 0.05 to 0.17 tall.

How often does the price come back?

From here on: the last candle that went the other way, a move that leaves a gap, the zone from the wicks. The zone's side nearer the price is its near edge, the other side its far edge. On the day you saw, the move was complete at the 10:50 candle's close, 106.22, above the zone of 106.10 to 106.16. Guess: of 100 order blocks, how many are touched again (a later bar reaches the near edge) by 16:00 the same day?

Order blocks the price came back to by 16:00, of 100 (simulated)

Counted over 1,000 simulated markets: a later bar reached the near edge (touched), the zone's middle, or the far edge (gone through).

This market, all ten years, touched?
1,000 markets?

Across the 1,000 simulated markets, 80.0 order blocks in 100 were touched by 16:00; in 70.1 the price got as far as the zone's middle, and in 61.7 all the way through it. On the day shown, the next bar touched it.

Why so often? The move has only just left the zone, so the near edge sits close to the price, and the price has hours left to wander. Is the zone pulling it back, or is any level that close reached as often? The next card checks.

The mirror test

For each order block, take each level's distance from the price when the move is complete, and put a mirror level the same distance on the other side. On the day you saw, the near edge, 106.16, was 0.06 below the price of 106.22, so its mirror is 106.28. Nobody calls a mirror level an order block. If order blocks pull the price back, their levels should be reached more often than their mirrors.

Order-block levels and their mirror levels reached by 16:00, of 100 (simulated)

Orange: the order blocks' levels. Grey: the mirror levels. 1,000 simulated markets.

The mirror levels were reached almost as often: 79.7 in 100 against 80.0 touched; 70.0 against 70.1 at the middle, 61.4 against 61.7 gone through. In these markets the return rate is mostly a base rate (how often something happens anyway, before any rule acts on it): a level that close is reached that often, order block or not. (On the day shown, the near edge's mirror was never reached.)

The order blocks' share touched was still 0.3 in 100 higher on average (higher in 787 of the 1,000 markets). The Theory card asks whether that is luck, and where it comes from.

For the preciseThe same 100 markets with the setting used here (bridge "normal"): 80.0 touched against 79.7 mirrors; with the pull-back setting (bridge "t"), gone through 61.7 against 60.7. Highs and lows: this simulation draws a bar's high and low a random distance beyond its open and close rather than from a price path. In 19,990 sessions of a plain random walk with the same bar sizes, highs and lows from the path gave 11.42 order blocks a day, touched 78.0 in 100 with mirrors 78.0; the generator's way gave 10.68, 79.5 and 79.4. The drift: order blocks before a move up were touched 79.7 times in 100 against 80.0 for their mirrors, before a move down 80.4 against 79.4. Opens: each bar opens where the one before closed; in 41.7 in 100 order blocks the candle was the bar right before the displacement bar, which then opened exactly at the candle's close. Each market's touched share ran from 79.3 to 80.8 in 100.

A rule, and its versions

A rule built on the idea: take the day's first order block. Before a move up, an order waits to buy at the middle of the zone; before a move down, it does the mirror image (sells first and buys back later, which gains when the price falls). A stop, a set price that ends a losing trade, sits at the far edge. Every trade ends by 16:00. One more choice: when is the zone used up (no longer valid, so the waiting order is cancelled)? At its first touch (if the bar that reaches the near edge doesn't also reach the middle, no trade that day), or only when a bar closes beyond the far edge, so the order keeps waiting.

Each set of choices is a version: the same idea with different settings (the How we test an idea lesson). Candle (two), displacement (three), zone (two), used up (two): how many versions?

That adds the choices (2 + 3 + 2 + 2). Every choice goes with every other, so they multiply.
That leaves out one of the two-way choices. Multiply all four.
2 candles × 3 displacements × 2 zones × 2 used-up rules = 24 versions.

One version against just holding

Start with one exact rule: the last opposite candle, displacement that leaves a gap, the wick zone, used up at the first touch. Call it the baseline version: this lesson's starting point, not anyone's published rule. On the day you saw, it bought at 106.13 in the 10:55 bar, and the stop at 106.10 ended the trade in the 11:05 bar.

It runs from 2015 to 2021 against just holding (buying once, never selling). Each buy and each sale costs 0.1% of the price (the Costs lesson); holding pays that once. Results are in % a year: the steady yearly growth that gives the same total. Holding made 4.4% a year. Where did the baseline version end, after costs?

The baseline version and just holding, 2015–2021, after costs (simulated)

Accounts starting at 100. Orange: the baseline version. Dotted: holding.

Your guess: it ends
Baseline version?
Holding?

It lost 11.0% a year after costs. It traded on 62 days a year, paying 0.1% to buy and 0.1% to sell each time. Each of those days keeps 0.998 of the account; 0.998 multiplied 62 times is 0.88, so costs alone take about 12% of the account a year. Before costs it made 0.8% a year.

One market is one draw, so run it on 1,000 more.

The baseline version against holding on 1,000 simulated markets, 2015–2021

Bars: markets, by the version's % a year minus holding's. Grey: after costs. Orange outline: before costs.

On 2015–2021 it beat holding before costs in 131 of the 1,000 simulated markets; after costs, in 2. Its trades averaged +0.0002% before costs: about zero.

For the preciseAgainst holding it averaged −8.35 points a year before costs and −20.02 after on 2015–2021, and −20.45 after costs on 2022–2024, where it beat holding in 30 of the 1,000 simulated markets. 91.9 in 100 of its trades ended at the stop and 8.0 in 100 gained. Holding owns this simulated market's slow rise day and night; the rule is in the market for part of some days and sells short about half the time.

All 24 versions

Here are all 24 versions on the same simulated market and years, 2015 to 2021. Each bar is a version's % a year minus holding's, its lead, in points (a point is 1% a year). Show them, then turn the costs on.

24 versions: each one's lead over holding, 2015–2021 (simulated)

One bar per version, grouped by candle, then by displacement (2 ×, 3 ×, gap). In each set of four: wick zone then body zone, each used up at the first touch, then when closed through. Above the line: beat holding. Black: the baseline version. Solid orange: the best.

Costs
Beat holding?
The best?

On this market none of the 24 beat holding on 2015–2021, before or after costs. The best after costs took the candle with the lowest low (highest high, before a move down), 3 × the average body, the wick zone and the first touch: −11.6 points a year. The baseline version came 5th: its place, counting from the largest lead.

The six with the largest leads after costs are the six that traded least here, wick zones used up at the first touch: 38.5 to 70.7 days a year, against 96.5 to 213.1 for the other 18. Every trade pays costs, so on a market with nothing to find, trading less loses less. On the 1,000 simulated markets, after costs, at least one of the 24 beat holding on 2015–2021 in 14.

Does the best stay best?

Before any version was run, 2022 to 2024 were set aside: years held out (set aside, to be used once; the held-out test lesson). On each of the 1,000 simulated markets we took the best of the 24 on 2015–2021, after costs, and ran it once on 2022–2024.

Two comparisons. A blind draw, one version taken at random, would be best there in about 42 of 1,000 (1,000 ÷ 24 = 41.7). But the best was mostly the version that trades least: the same one in 817 of the 1,000 markets, trading on 37.9 days a year against 132.6 for the 24 on average. So the fair comparison is the least-trading version, chosen in advance by its number of trading days on 2015–2021, without looking at its results. Guess how often the best stayed best.

The best version's place on 2022–2024, on 1,000 simulated markets, after costs

One bar per place, 1st on the left. Dashed: a blind draw. Dotted: the least-trading version, best in this many markets.

The best stayed best?
Least-trading version best?

The best stayed best in 592 of the 1,000 simulated markets. The least-trading version, chosen without looking at any result, was best there in 662; a blind draw, in about 42. Picking by results did no better than counting trades: the best stayed on top mostly because it traded least. It is not skill, and it says nothing about a real market.

For the preciseOn 2022–2024, after costs, the best beat holding in 75 of the 1,000 simulated markets, all 75 of them markets where holding itself lost money there (holding lost in 229 of the 1,000): cash beat a falling market. The least-trading version beat holding in 76, all of them markets where holding lost. The best was the least-trading version in 817 markets; it took the candle with the lowest or highest extreme in all 1,000 and was used up at the first touch in all 1,000. Average held-out place: the best 1.5, the least-trading version 1.4. No market had a tie for first place.
Theory

Is a small difference luck? The standard error

The order blocks were touched 0.3 times in 100 more often than their mirrors. To ask whether that is luck, measure the difference in each of the 1,000 markets and average them. An average of n independent numbers spreads around its true value by their standard deviation divided by √n: the standard error (the Sampling error lesson). Dividing the average by it, z, says how many standard errors it sits from zero. On the bell curve (the usual hump-shaped spread of luck), beyond 2 either way happens about 5 times in 100 if only luck is at work.

SE = s ÷ √n
z = average ÷ SE
n
the number of independent measurements (here, markets)
s
their standard deviation: how far a typical one sits from their average
SE
the standard error: how far luck typically moves the average of n such measurements
z
how many standard errors the average sits from zero; for an average of many independent measurements, beyond 2 either way happens about 5 times in 100 if only luck is at work
Worked example: the 1,000 markets

Each market's touched share minus its mirror share, in order blocks per 100: average 0.301, standard deviation s = 0.380, n = 1,000. SE = 0.380 ÷ √1,000 = 0.380 ÷ 31.6 = 0.0120. z = 0.301 ÷ 0.0120 = 25: far beyond luck.

So where does it come from? The first 100 of the markets, rebuilt with a first price of 100,000 so that rounding prices to the cent no longer matters, gave 80.0 touched against 80.1 for the mirrors; at the usual price the same 100 gave 80.0 against 79.7. Once rounding to cents was removed, the lead vanished, so it most likely came from rounding, not from order blocks.

Holds when
  • the measurements are independent of each other (separate markets, not overlapping stretches of one);
  • there are enough of them for their average to follow the bell curve (dozens or more).
Breaks when

Measurements that move together make the true spread wider than s ÷ √n. And a large z only says a difference is not luck; it does not say what made it. Here it was how the prices were built.

Across 400 simulated markets, the differences average 0.5 in 100 with a standard deviation of 4 in 100. How many standard errors is the average from zero?

SE = 4 ÷ √400 = 4 ÷ 20 = 0.2; z = 0.5 ÷ 0.2 = 2.5.
First the standard error: 4 ÷ √400 = 4 ÷ 20 = 0.2 in 100. Then 0.5 ÷ 0.2 = 2.5 standard errors from zero.

What this means for your test

  1. Write the exact definition before you count.

    Which candle; what counts as displacement; a wick or body zone; when it is used up; and, for a rule, the entry, the stop and the costs.

Practice 1 of 3

"Price always returns"

The situationAn invented post says that 4 in 5 order blocks get touched again the same day, so big traders' orders must be waiting there.

Which count would tell you whether order blocks pull the price back?

More days make the 4 in 5 more precise, but it still has nothing to compare with: a level that close may be reached that often anyway.
A stronger move leaves the zone further away, so it is touched again less often, with or without a pull. The count still needs something to compare with.
A mirror level, the same distance from the price on the other side, shows how often a level that close is reached with no order block. In this lesson's simulated markets the two were within 0.3 points.
Practice 2 of 3

A seller's difference

The situationAn invented course says its order blocks were touched again 2 times in 100 more often than mirror zones, averaged over 25 separate markets. The 25 differences have a standard deviation of 5 in 100.

How many standard errors is the average of 2 in 100 from zero?

Hint: first work out SE = s ÷ √n, then divide the average by it.

SE = 5 ÷ √25 = 1 in 100; 2 ÷ 1 = 2. That is at the edge of what luck does about 5 times in 100, and even a larger z would leave the question of how the data were built.
SE = 5 ÷ √25 = 5 ÷ 5 = 1 in 100, so the average is 2 ÷ 1 = 2 standard errors from zero: at the edge of what luck does about 5 times in 100.
Practice 3 of 3

The best of 30

The situationA friend tested 30 versions of an order-block rule on 1,000 simulated markets with nothing to find. The best after costs stayed best on held-out years in 300 of them, against about 33 for a blind draw. It is nearly always the version that trades least.

What should they compare the 300 with?

A blind draw ignores costs. A version that trades least loses least to costs in any years, so it beats 33 without any skill.
Choose the least-trading version in advance, by its trade count alone, and count how often it is best on the held-out years. If that is about 300 too, picking by results added nothing, as in this lesson (592 against 662).
More markets make the 300 more precise, but it would still be compared with the wrong yardstick.
✓

Lesson done

An order block is the last candle that went the other way before a strong move; which candle, what counts as a strong move (displacement), a wick or body zone and when it is used up are choices, and they made 24 versions here. These simulated markets were built so that past prices say nothing about which way the next move goes, so the counts show what happens when there is nothing to find: 80.0 order blocks in 100 were touched again the same day, and mirror levels the same distance on the other side were reached 79.7 times in 100; the remaining 0.3 in 100 vanished once rounding prices to cents was removed, so it most likely came from that rounding. After costs the baseline version beat holding on 2015–2021 in 2 of the 1,000 simulated markets. The best of 24 stayed best on held-out years in 592, mostly because it traded least: the least-trading version, chosen in advance, did so in 662 (a blind draw: about 42). The counts cannot show whether order-block rules work in any real market.

Key ideas

Order block
the last candle that went the other way before a strong move (one common reading); another reading takes the candle with the lowest low (highest high) before it
Displacement
the strong move itself; defined, among other ways, as a candle body at least 2 or 3 times the recent average, or a move that leaves a fair value gap
Zone, near edge, far edge
the order block's price range, from its wicks or its body; its side nearer the price, and the other side
Mirror level
a level the same distance from the price on the other side; the base rate an order block's return rate is compared with
Least-trading version
the version with the fewest trading days, chosen before looking at results; the fair yardstick for a best version when costs favour trading less

Formulas

SE = s ÷ √n: the standard error of an average of n independent measurements whose standard deviation is s

z = average ÷ SE: how many standard errors an average sits from zero; for many independent measurements, beyond 2 either way about 5 times in 100 by luck

Lesson notes

An order block is the last candle that went the other way before a strong move. Which candle, what counts as a strong move (displacement), whether its zone is read from the wicks or the body, and when it is used up are choices; they made 24 versions in this lesson. Its simulated markets were built so that past prices say nothing about which way the next move goes, so its counts show what order blocks and rules built on them do when there is nothing to find. In them most order blocks were touched again the same day, and levels the same distance on the other side of the price were reached almost as often. After costs the baseline version beat just holding on 2015–2021 in 2 of 1,000 simulated markets. The counts cannot show whether order-block rules work in any real market; that needs its own test.

The candle and the move

The lesson's simulated market (prices made up by a computer) has one session a day, 09:30 to 16:00, in 78 five-minute bars, each a candle: a line (the wick) from its low to its high and a box (the body) from its open to its close. Displacement had three readings: a candle that closed the move's way with a body at least 2 times, or at least 3 times, the average body of the 20 candles before it; or a move that leaves a fair value gap (three candles whose first and third don't overlap). The order block was searched among the five candles before the move and counted once the move's close was clear of it. On the lesson's example day (16 January 2017 in the simulation) the three readings found 4, 2 and 4 order blocks; across 1,000 simulated markets, 6.8, 1.9, 9.0 a day.

Which candle, which zone

The candle is either the last one that went the other way before the move (for a move up, the last that closed lower) or the one with the lowest low (highest high, before a move down) among the five before it. The zone is the candle's range from the wicks, or its body. On the example day the first move up that left a gap came at 10:45. The last candle that closed lower was the 10:30 bar, with a zone of 106.10 to 106.16 from the wicks and 106.11 to 106.16 from the body; the lowest low was the 10:20 bar, which closed higher, with 106.00 to 106.17 or 106.06 to 106.15. One move gave four zones from 0.05 to 0.17 tall.

How often the price comes back, and the mirror test

With the last opposite candle, displacement that leaves a gap and the wick zone, the near edge is the zone's side nearer the price, the far edge the other side. Across the 1,000 simulated markets, of 100 order blocks, 80.0 were touched (a later bar reached the near edge) by 16:00, 70.1 were reached at the middle and 61.7 were gone through (a bar reached the far edge). A mirror level sits the same distance from the price when the order block is confirmed, on the other side (the example's near edge, 106.16, was 0.06 below the price of 106.22; its mirror was 106.28). The mirrors were reached 79.7, 70.0, 61.4 times in 100: in these simulated markets the return rate is mostly a base rate (how often something happens anyway). The order blocks' share touched was still 0.3 in 100 higher on average (higher in 787 of the 1,000 markets); that lead vanished when 100 of the markets were rebuilt at a first price of 100,000, where rounding to the cent no longer matters (80.0, 80.1), so it most likely came from rounding.

A rule, just holding, and the best of 24

The rule takes the day's first order block: an order buys (before a move up) or sells short (before a move down; selling first, buying back later) at the zone's middle; a stop (a set price that ends a losing trade) at the far edge; out by 16:00. The zone is used up at its first touch (no trade if that bar doesn't reach the middle) or only when a bar closes beyond the far edge. That makes 2 × 3 × 2 × 2 = 24 versions. The baseline version (last opposite candle, a gap, the wick zone, the first touch) ran from 2015 to 2021 against holding, with 0.1% of the price on every buy and sale. On the lesson's simulated market holding made 4.4% a year after its one cost; the baseline version lost 11.0% a year after costs (% a year: the steady yearly growth that gives the same total). It traded on 62 days a year, and 0.998 multiplied 62 times is 0.88, so costs alone took about 12% of the account a year. On the 1,000 simulated markets, on 2015–2021, it beat holding before costs in 131 and after costs in 2. On the lesson's market none of the 24 beat holding on 2015–2021, and the six with the largest leads after costs were the six that traded least. With 2022 to 2024 held out (set aside, used once), the best of 24 on 2015–2021 (after costs) stayed best there in 592 of the 1,000 simulated markets. It was the least-trading version in 817 of them, and the least-trading version, chosen in advance by its trade count alone, was best on the held-out years in 662; a blind draw would be best in about 42 (1,000 ÷ 24). The best stayed on top mostly because it traded least. That is not skill, and it says nothing about a real market.

Formula: the standard error

An average of n independent measurements spreads around its true value by their standard deviation divided by √n; dividing the average by that standard error says how many standard errors it sits from zero.

SE = s ÷ √n
z = average ÷ SE
n
the number of independent measurements
s
their standard deviation: how far a typical one sits from their average
SE
the standard error: how far luck typically moves their average
z
standard errors from zero; for an average of many independent measurements, beyond 2 either way about 5 times in 100 if only luck is at work
Worked example: the 1,000 markets

Each market's touched share minus its mirror share, in order blocks per 100: average 0.301, standard deviation 0.380, 1,000 markets. SE = 0.380 ÷ 31.6 = 0.0120; z = 0.301 ÷ 0.0120 = 25, far beyond luck. Rebuilt at a first price of 100,000, the first 100 markets gave 80.0 touched against 80.1 mirrors (80.0 against 79.7 at the usual price): once rounding to cents was removed the lead vanished, so it most likely came from rounding.

Holds whenBreaks when

Measurements that move together make the true spread wider. A large z only says a difference is not luck, not what made it.

One more worked example

Made-up round numbers

A study measures, in 100 separate simulated markets, how much more often zones are touched again than their mirrors. The 100 differences average 0.8 in 100 with a standard deviation of 6 in 100. SE = 6 ÷ √100 = 0.6 in 100; z = 0.8 ÷ 0.6 = 1.3: well inside what luck does. With 10,000 markets and the same average and spread, SE = 6 ÷ 100 = 0.06 and z = 13: not luck, but still no word on what caused it, until the data's construction is checked.

Common mistakes

Check yourself

  1. Before a move up, the last candle that closed lower has a high of 50.20, a low of 49.90, an open of 50.15 and a close of 50.00. What is its zone from the wicks, and from the body?
    Answer

    From the wicks, 49.90 to 50.20 (0.3 tall); from the body, 50.00 to 50.15.

  2. Differences measured in 900 separate markets average 0.6 in 100 with a standard deviation of 9 in 100. How many standard errors from zero is the average?
    Answer

    SE = 9 ÷ √900 = 9 ÷ 30 = 0.3; z = 0.6 ÷ 0.3 = 2.

  3. A test uses two candle readings, two displacement readings, one zone and three used-up rules. How many versions?
    Answer

    2 × 2 × 1 × 3 = 12.

  4. In the lesson's simulation the best of 24 stayed best on held-out years in 592 of 1,000 markets, against about 42 for a blind draw. Does that show that picking the best version found something real?
    Answer

    No. The least-trading version, chosen in advance without looking at results, was best in 662. The best stayed on top mostly because it traded least and so paid the least in costs, in markets built with nothing to find.

Try it yourself

The rules, written before the code. Five-minute bars, one session a day. A bar is up if close > open, down if close < open; its body is |close − open|; the average body before bar d is the mean body of the 20 bars before it (reaching into the day before). Displacement up at bar d: an up bar with a body at least 2 (or 3) × that average, or an up bar d with bar d + 1's low above bar d − 1's high (a gap; known one bar later). The order block, among the up to 5 bars of the session before d: the latest down bar, or the bar with the lowest low (the earliest on a tie). Zone: low to high, or the body. It counts if the confirming bar's close is above the zone and a bar follows; a candle is counted once. Down order blocks are the mirror image. Returns: a later bar's low (high) reaching the near edge, the middle or the far edge by 16:00; mirror: 2 × the confirming close − the level. The rule: the day's first order block; an order at the zone's middle buys (up) or sells short (down); used up at the first touch (the touching bar must reach the middle) or when a bar closes beyond the far edge; a stop at the far edge, watched from the entry bar; out at 16:00. 0.1% of the price per buy and per sell, or no costs. Compared with buying at the first close and holding, which pays 0.1% once.

Run the script. Every number in this lesson comes from one Python script (below). It imports simmarket.py, the course's simulated market, which must sit in the same folder. Add an order block that may last into the next day, or a fourth candle reading, and watch the counts and the versions move.

By hand. In a spreadsheet with one row per five-minute bar (open in B, close in E), a bar's body is =ABS(E2-B2), and the average body of the 20 bars before row 22 is =AVERAGE(F2:F21) when the bodies are in column F.

Written by QuantWright from plain-word definitions of the order block, displacement, its zone and when it is used up, and the rules above. No code from any indicator script or charting platform.

The code behind every number (Python, imports SimMarket, seed 20261109)
Loading…
For the preciseThe lesson's market: SimMarket Market 1, seed 20261109, effect=False (no planted pattern), five-minute bars built with bridge="normal" (no pull-back within the day), the same bars as the Fair value gaps lesson. The 1,000 simulated markets: the same generator and setting with seeds 2026241401 to 2026242400. Choosing years: from the close of 5 Jan 2015 to 31 Dec 2021 (6.99 calendar years); held-out: to 31 Dec 2024 (3.00 years). % a year = (the account's growth factor)1 ÷ years − 1; a long trade's return is exit ÷ entry − 1, a short trade's 1 − exit ÷ entry; after costs each traded day is multiplied by 0.999². The lesson's market: holding 4.38% a year before its cost, 4.36% after (choosing), 10.00% (held-out). Baseline order blocks over its 2,607 days: 11,776 before a move up and 11,692 before a move down; touched 18,868, middle 16,614, gone through 14,609; their mirrors 18,778, 16,455 and 14,474. Baseline version: +0.80% a year before costs, −10.98% after (434 trading days, 62.1 a year), lead −3.58 then −15.34, 5th of 24; held-out lead −22.94, 5th. The best after costs (lowest or highest candle, 3 ×, wick, first touch): lead −3.99 before costs, −11.63 after (39.6 trading days a year); held-out lead −15.23, 1st. The least-trading version on this market (lowest or highest candle, gap, wick, first touch): 38.5 trading days a year, 2nd after costs, 2nd held-out. Over the 1,000 markets the six "first touch, wick" versions traded on 37.4 to 72.6 days a year, the other 18 on 93.8 to 210.2. Two of the 1,000 markets closed below $30 at some point (the lowest close, $26.82).

Honest notes

Where this comes from