Testing Popular Ideas · Lesson 13
SMC: fair value gaps
Three candles, a space between the first and the third, and the saying that the price comes back to fill it: how often it does when there is nothing to find, and the 24 versions of a rule built on it.
Know the basics? Read the lesson notesThree candles and a gap
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 three candles in a row. A candle (also called a bar) holds the open and close (the first and last price of a stretch of time; here, five minutes) and the high and low in between. If the third candle's low is above the first candle's high, the middle one rose so fast that the first and third never overlap. The empty space between them is a fair value gap; this one is an up gap, and the same picture upside down is a down gap. A popular saying is that the price tends to come back and fill the gap.
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 gaps and gap rules do when there is nothing to find. They cannot show whether the idea works in a real market.
Three made-up sets of three candles
Each candle: a thin line from its low to its high, a box from its open to its close, empty if it closed higher.
Which set shows an up fair value gap, judged by the highs and lows?
Wick or body
Traders read gaps two ways. From the wicks (the thin lines: highs and lows), as on the last card, or from the bodies (the boxes): the bottom of the third candle's box against the top of the first's. The chart is one simulated day, 09:30 to 16:00. Try both readings.
Every gap of one day, two readings (simulated)
Shaded bands: each gap, from its first candle to its third. Any size counts here.
This day has 11 gaps read from the wicks and 38 read from the bodies. Across 1,000 simulated markets: 14.6 a day from the wicks, 39.5 from the bodies.
Why so many from the bodies? In these markets each bar opens where the one before it closed. When three bars in a row close higher, the first and third boxes can't overlap: the middle bar's box is the gap. 42.1 in 100 of the up gaps read from the bodies were exactly that.
How big must a gap be?
A gap of one cent counts as much as a gap of a dollar unless you set a minimum size. Here it is measured as the gap's height in % of the third candle's close: any size, at least 0.05%, or at least 0.10%. Try all three on the same day, read from the wicks.
The same day, gaps read from the wicks, by minimum size (simulated)
Shaded bands: the gaps that are at least the chosen size.
11 gaps, then 2, then 1 on this day. Across the 1,000 simulated markets: 14.6, 6.3 and 2.7 a day. At this day's price of about 106, a cent is about 0.01%, so 7 of this day's 11 are a cent or two.
When is a gap filled?
Three common answers, for an up gap: the price comes back down to the gap's top edge, its near edge (the gap is touched); to its middle (half filled); or to its bottom edge, its far edge (fully filled: the whole gap traded through). A later bar's low reaching the level counts, in the same session (the same trading day). Below: the first gap of at least 0.05% on the same day, from 106.22 to 106.33. Try all three.
One gap and its fill, 09:30 to 11:15 (simulated)
Shaded: the gap. Dashed: the chosen level. Ring: the first later bar to reach it.
Touched in the very next bar: the third candle closed at 106.33, the gap's top, so the next bar opened right on it. Half filled in the 10:00 bar, fully filled in the 10:05 bar.
How often do gaps get filled?
From here on the gaps are read from the wicks and are at least 0.05%. Guess: of 100 such gaps, how many are fully filled before 16:00 the same day?
Gaps filled by 16:00, of 100 (simulated)
Counted over 1,000 simulated markets, every gap of at least 0.05% read from the wicks.
Across the 1,000 simulated markets, 73.9 gaps in 100 were fully filled by 16:00; 87.8 were touched and 80.3 half filled. So "gaps get filled" is true here most of the time, in markets built with nothing to find.
Why? The near edge sits at or just below the third candle's close, and the price has hours left to wander. Is the gap pulling it back, or is any level that close reached as often? The next card checks.
The mirror test
For each gap, take each level's distance from the third candle's close and put a mirror level the same distance on the other side. On the day you saw, the far edge, 106.22, was 0.11 below the close of 106.33, so its mirror is 106.44. Nobody calls a mirror level a gap. If gaps pull the price back, their levels should be reached more often than their mirrors.
Gap levels and their mirror levels reached by 16:00, of 100 (simulated)
Orange: the gap's levels. Grey: the mirror levels. 1,000 simulated markets.
The mirror levels were reached about as often: 73.7 in 100 against 73.9 for the far edges; 87.5 against 87.8 touched, 80.2 against 80.3 half filled. In these markets the fill rate is a base rate (how often something happens anyway, before any rule acts on it): a level that close is reached that often, gap or no gap.
A second generator setting adds a small within-day pull-back; there the far edge was reached in 72.6 in 100 and its mirror in 71.4, a difference of about 1. This lesson uses the setting without it.
For the precise
The pull-back setting (bridge "t") against the one used here (bridge "normal"), the same 100 markets: far edge 72.6 against mirror 71.4, against 73.9 and 73.6. With the setting used here the far edge sat above its mirror in 650 of the 1,000 markets and below in 345, by 0.2 points pooled; most of that comes from rounding prices to the cent (the same 100 markets at 1,000 times the price: far edge 73.4, mirror 73.4). The slow upward drift fills up gaps a little less often than their mirrors (73.5 against 74.1) and down gaps a little more (74.3 against 73.3). 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 20,000 sessions of a plain random walk with the same bar sizes, highs and lows taken from the path gave 9.28 gaps a day of at least 0.05%, fully filled 70.9 in 100 with mirrors 70.9; the generator's way gave 7.67, 73.3 and 73.3. The fill rate depends on how highs and lows are made; the match with the mirrors does not. Each market's fully-filled share ran from 72.3 to 75.6 in 100.A rule, and its versions
A rule built on the idea: take the day's first gap. For an up gap, an order (an instruction to trade) waits to buy when the price comes back to the near edge, or to the middle; for a down gap it sells short there (sells first and buys back later, so the trade gains when the price falls). A stop, a set price that ends a losing trade, sits at the far edge, or there is none. Every trade ends by 16:00. One trade a day at most; if the price never comes back, no trade.
Each set of choices is a version: the same idea with different settings (see the How we test an idea lesson). Reading (wicks or bodies), minimum size (three), entry, stop: how many versions?
One version against just holding
Start with one exact rule: wicks, at least 0.05%, enter at the near edge, stop at the far edge, out at 16:00. Call it the baseline version: this lesson's starting point, not anyone's published rule.
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 giving 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.
It lost 38.4% a year after costs. It traded on 227 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 227 times is 0.63, so costs alone take about 37% of the account a year.
One market is one draw, so run it on 1,000 more.
The baseline version against holding on 1,000 simulated markets
Bars: markets, by the version's % a year minus holding's. Grey: after costs. Orange outline: before costs.
On 2015 to 2021, before costs, it beat holding in 117 of the 1,000 simulated markets; after costs, in none. Its trades averaged −0.0013% before costs: about zero.
Notice where its trades ended: 86.5 in 100 at the stop (these are the gaps the rule traded, a different group from the 73.9 in 100 of all gaps that were filled). The stop is the gap's far edge, so a gap that is fully filled after the entry ends the trade at a loss. The fill the saying promises is this rule's stop.
For the precise
Against holding it averaged −8.97 points a year before costs and −44.81 after, across the 1,000 simulated markets; its trades gained in 13.0 in 100. On the market shown it lost 3.0% a year before costs. Holding owns this simulated market's slow rise day and night; the rule is in the market for part of each day 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, 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 reading. Above the line: beat holding. Black: the baseline version. Solid orange: the best.
On this market 7 of the 24 beat holding before costs, and none after. The best after costs read the wicks, needed at least 0.10%, entered at the middle and had no stop: −28.1 points a year. The baseline version came 19th of 24: its place, counting from the version furthest ahead of holding.
On 2015 to 2021, after costs, none of the 24 beat holding in any of the 1,000 simulated markets.
For the precise
Before costs, at least one of the 24 beat holding in 395 of the 1,000 simulated markets (3.84 versions on average).Does the best stay best?
Before any version was run, 2022 to 2024 were set aside: years held out, to be used once (see 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. 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 24 don't cost the same: versions that trade on fewer days pay less in costs. So a fairer comparison is the version that trades least (wicks, at least 0.10%, entry at the middle, with the stop), chosen in advance without looking at any result: it was best on 2022–2024 in 381 of the 1,000. 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.
The best stayed best in 422 of the 1,000 simulated markets, against a blind draw's 42. It beat holding there, after costs, in 1.
Why 422, close to the 381 of the version chosen in advance? Mostly because it traded least: in 963 of the 1,000 markets the best was that version or the same version without the stop, which trades on the same days (134.8 a year, the other 22 on 150.1 to 245.5), so the two pay the least in costs. When the best came 2nd (219 markets) or 3rd (237), the version ahead of it was mostly its twin (161 and 217 of those). It is not skill, and it says nothing about a real market.
Reaching a level: the reflection principle
If a price has no pattern in which way it moves, the chance it reaches a level depends only on how far away the level is and how much the price will move before time runs out. The reflection principle: the chance of touching a level is twice the chance of ending beyond it, because every path that touches it and ends back on the near side has a twin, flipped at the level, that ends beyond it. The formula has no "gap" in it: only distance, σ and time; that is why the mirror level is reached just as often.
- d
- the distance from the price now to the level
- σ
- the standard deviation of one bar's move (how far a typical bar moves, as in the Volatility lesson)
- n
- the number of bars left; √n is its square root (√9 = 3)
- Φ(z)
- the chance that a draw from the bell curve (the hump-shaped spread of many random results; the Bell curve lesson) is below z standard deviations; in a spreadsheet,
NORM.S.DIST(z,TRUE) - P(reach)
- the chance the price touches the level before time runs out, for a price with no drift (no steady rise or fall) and no pattern in which way it moves, moving in small steps of a steady size
On the day shown, the far edge, 106.22, was 0.11 below the third candle's close of 106.33: d = 0.11 ÷ 106.33 = 0.103%. That day's 78 five-minute moves had a standard deviation of σ = 0.059%, and n = 73 bars were left (this σ uses the day's own moves, which a trader would not know in advance). So σ × √73 = 0.059% × 8.54 = 0.504%; d ÷ 0.504% = 0.20; Φ(0.20) = 0.58; P = 2 × (1 − 0.58) = 0.84, about 84 in 100. It was reached three bars later.
Across the 1,000 simulated markets, using each gap's own distance and what the rest of its day's moves added up to, the formula gives 72.0 in 100 for the far edge; a later close reached it in 65.7, and a later low or high in 73.9.
- from any price, an up move is as likely as a down move, with no drift (a steady rise or fall);
- the price moves in small steps of a steady size.
Counting only closes misses touches between them (65.7 above). A pull-back raises the chance; a drift raises it on one side and lowers it on the other.
A gap's far edge is 0.30% below the price. Each bar's move has a standard deviation of 0.05%, and 9 bars are left. The bell curve puts 95.4 draws in 100 within 2 standard deviations of the middle. About how many gaps in 100 like this one are fully filled?
Hint: work out σ × √n and how many of those the edge is away. Only one side counts, so halve what lies outside ±2, then double it for touching.
What this means for your test
- Write the exact definition before you count.
Wicks or bodies; the minimum size; which level counts as filled; the same session or longer; and, for a rule, the entry, the stop and the costs.
- Compare the fill rate with a base rate, and the rule with just holding after costs.
In these simulated markets 73.9 gaps in 100 were fully filled and their mirror levels were reached 73.7 times in 100. On 2015 to 2021 the baseline version trailed holding after costs in all 1,000.
- Count the versions, then hold out years.
24 here. The best of 24 stayed best on held-out years in 422 of 1,000 simulated markets, against about 42 for a blind draw and 381 for the least-trading version chosen in advance, mostly because it traded least: not a sign that gaps work.
"Gaps always fill"
Which count would tell you whether the gaps pull the price back?
A wider gap
For a price with no pattern and no drift, about how many gaps in 100 like this are fully filled?
Hint: first work out σ × √n, then how many of those the edge is away.
A bigger search
In about how many of the 1,000 would a blind draw be best?
Hint: first multiply the choices to get the number of versions, then divide 1,000 by it.
Lesson done
A fair value gap is the space between the first and third of three candles when they don't overlap; reading it from wicks or bodies, its minimum size and when it counts as filled are choices, and with a rule's entry and stop 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: 73.9 in 100 gaps (wicks, at least 0.05%) were fully filled the same day, and mirror levels the same distance on the other side were reached 73.7 times in 100. On 2015 to 2021, after costs, none of the 24 beat just holding in any of the 1,000 simulated markets; the best of 24 stayed best on held-out years in 422 (a blind draw: about 42; the least-trading version chosen in advance: 381), mostly because it traded least. The counts cannot show whether gap rules work in any real market.
Key ideas
- Fair value gap
- three candles in a row whose first and third don't overlap; the space between them. Up gap: the third's low above the first's high (wick reading)
- Wick, body reading
- comparing the candles' highs and lows, or their open-to-close boxes; when each bar opens at the last close, three bars closing the same way make a body gap
- Near edge, far edge
- the gap's side nearer the price now, and the other side; touched, half filled and fully filled mean the price came back to the near edge, the middle or the far edge
- Mirror level
- a level the same distance from the price on the other side; the base rate a gap's fill rate is compared with
- Version
- the same idea with different settings; count every one
Formulas
P(reach) = 2 × (1 − Φ(d ÷ (σ × √n))), for a price with no drift and no pattern in which way it moves, moving in small steps of a steady size: d the distance to the level, σ one bar's standard deviation, n the bars left (the reflection principle)