Smart money concepts: can an algo backtest order blocks and FVGs?
Order blocks and fair value gaps can be backtested only after every drawn choice is written as a number. A fair value gap needs three candles and two settings; an order block needs five. The result then grades your written definition of the pattern, not the concept as it is drawn by hand.
By Soren Huang · Published · updated · Editorial policy
Contents
- Can order blocks and fair value gaps be turned into testable rules?
- What is an order block and what is a fair value gap?
- How do you define an order block objectively?
- How do you code a fair value gap?
- Why is ambiguity the real problem, and how do ICT and SMC differ?
- What does a futures backtest of a stand-in rule on NQ show, and how do you read it?
- Does SMC actually work?
- Frequently asked questions
- References
Can order blocks and fair value gaps be turned into testable rules?
Smart money concepts such as order blocks and fair value gaps can be used in algorithmic trading only once every hand-drawn choice is a written rule. A fair value gap needs three candles and two settings. An order block needs five. The backtest then grades your written definition, not the concept as it is drawn by hand.
Smart money concepts (SMC) is a family of chart-reading methods that tries to find where large participants placed their orders, using price bars alone. The methods are taught with marked-up charts. A computer cannot read a marked-up chart. It needs a rule it can apply to every bar in the same way, which is what algo trading is in practice: a written rule, run without judgment. So the first job is not coding. It is writing.
The two patterns are not equally hard to write. A fair value gap is a relation between three candles, and the only open questions are how large the gap must be and what counts as filling it. An order block is a candle picked by looking at what happened afterwards, so you must also decide which candle qualifies, how strong the following move must be, which prices form the zone, what a touch is, and when the zone stops counting. Each of those is a place where two traders disagree, and each must become a number before a test can run.
What is an order block and what is a fair value gap?
Both patterns are read from price alone, and the figure below shows exactly where each sits on a chart. An order block is the zone of the last candle of the opposite colour before a strong move: the last down candle before a sharp rise (a bullish order block) or the last up candle before a sharp fall (a bearish order block). The idea behind it is that large buyers or sellers filled their orders inside that candle and will defend the zone when price returns. A fair value gap (FVG) is the price space a fast move left untraded: in a run of three candles, the part of the middle candle's range that the first and third candles do not overlap. The idea behind it is that price tends to come back and trade through the space it skipped.
Neither pattern uses volume, open interest or order-book data. "Smart money" is a label for an interpretation, not a measured quantity. That matters for testing in a helpful way: because the inputs are only open, high, low and close, both patterns can be tested on any bar data you already have. They belong to the price-pattern group among the futures algo trading strategy types you can backtest, next to breakouts and candlestick patterns, and they inherit the same testing rules.
How do you define an order block objectively?
An order block becomes a rule only when you write down five settings in advance, and the choice of each one is yours. The settings below are the minimum. Where a setting needs a size, state it in units of the Average True Range (ATR), so the same rule means the same thing on a quiet year and a wild one. The Average True Range is the average size of a bar's full movement over a chosen number of bars, including any gap from the previous close.
- Qualifying candle. The last candle whose close is below its open before an up move (or above its open before a down move). Decide whether a doji, where close equals open, counts.
- Move size. How far price must travel after the candle for it to count as "strong". Example: the close moves at least 2 ATR away from the candle's close within the next 3 bars.
- Zone edge. Which prices form the zone. Common choices are open to low of a bullish block, or high to low of the whole candle. Pick one.
- Touch rule. What counts as price returning to the zone: a wick touching the upper edge, a close inside the zone, or a close inside followed by a close back above it.
- Expiry. When the zone stops counting: after a fixed number of bars, after the first touch, or after price closes through the far edge.
Hypothetical example
Suppose the 14-bar ATR is 100 points. A down candle opens at 18,000 and closes at 17,950, with a low of 17,920. Over the next 3 bars the close reaches 18,180, which is 230 points above 17,950, more than the required 2 ATR (200 points). The candle qualifies as a bullish order block with a zone from 17,920 to 18,000. The rule says: buy on the next bar's open after the first close inside the zone, as long as the touch happens within 20 bars. If no touch comes in 20 bars, the zone is deleted.
Write the five values down before the first run, and test the neighbouring values afterwards. A rule that only works when the move size is exactly 2.0 ATR, and fails at 1.8 and 2.2, is describing one stretch of history rather than a pattern.
How do you code a fair value gap?
A bullish fair value gap exists when the high of candle one is below the low of candle three, a bearish one when the low of candle one is above the high of candle three, and two more settings make the pattern fully mechanical. The one formula you need is:
bullish gap size = low of candle three − high of candle one
Here candle one is the oldest of the three bars, candle three is the newest, and the gap size is in price points. If the result is positive, a bullish gap exists. For a bearish gap, swap the sides: high of candle three subtracted from low of candle one. The two settings to add are:
| Setting | Why it is needed | Example choice |
|---|---|---|
| Minimum gap size | On any chart, tiny gaps appear constantly. Without a floor, the rule fires every few bars and costs eat the result. | At least 0.5 ATR |
| Fill rule | Decides when price has "returned to" the gap and when the gap is used up. | Entry when price trades to the gap midpoint; gap removed once price closes through its far edge |
Hypothetical example
Candle one has a high of 18,000. Candle three has a low of 18,060. The gap is 60 points. With a 14-bar ATR of 100 points, 60 points is 0.6 ATR, above the 0.5 ATR floor, so the gap is recorded with a midpoint of 18,030. Twelve bars later price trades down to 18,030, and the rule buys on the open of the following bar. The exit is a separate decision and must be written with the same care: a fixed number of bars, an ATR-based stop, or the next opposite gap.
With these two settings fixed, every bar in your history gets the same yes-or-no answer. That is the test of a mechanical rule: a second person with the same data and the same settings gets the same trade list.
Why is ambiguity the real problem, and how do ICT and SMC differ?
Two traders marking the same chart draw different blocks and gaps, and the ICT and SMC vocabularies differ enough that a backtest result belongs to one written variant and cannot confirm or refute the whole school. ICT (Inner Circle Trader) is a body of online lessons from one trader, built up over many years, with its own terms and a strong emphasis on time of day. SMC is a later, simplified version of those ideas that spread through forums and videos and reuses many of the same terms with different weight. When a trader says "I trade order blocks", you still do not know which five settings they use, whether they require a session window, or how they define the swing points that their structure terms depend on.
| Point of difference | ICT | SMC |
|---|---|---|
| Origin of terms | One teacher's lesson series, with a large and specific vocabulary | Community simplification of ICT material, smaller vocabulary |
| Time-of-day emphasis | Trades are taken in named session windows ("kill zones") around the London and New York opens | No session filter is required in most presentations |
| Core structures named | Order block, fair value gap, liquidity sweep (a move through a recent high or low that then reverses), market structure shift | Break of structure (a close beyond the last swing point with the trend), change of character (the first close beyond a swing point against the trend), order block, fair value gap |
| What a rule writer must fix | The session window in exchange time plus every structure setting | The swing definition (how many bars make a swing high or low) plus the block and gap settings |
This is why a result on "SMC" cannot exist. A result can exist for "bullish fair value gap, minimum 0.5 ATR, entry at midpoint, exit after 5 bars, NQ 15-minute bars, regular session only". Write the full sentence, and a backtest can grade it. Leave any part out, and the next person testing "the same thing" gets a different trade list.
What does a futures backtest of a stand-in rule on NQ show, and how do you read it?
Because no single fair value gap definition is agreed, the run behind this article, made with AlphaPrime (Valynox), tested a stand-in rule instead of a fair value gap itself: an Average True Range rule as the only entry and exit, with no stop, target or filter. The run used NQ (E-mini Nasdaq-100) daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with $20 commission and $10 slippage charged on every trade and next-bar execution. The engine tried 1,024 candidates and kept one for its return against its drawdown. The numbers below are that one kept candidate.
Source: AlphaPrime product engine (CPU), run 2026-10-31. NQ daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $10 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $233,415 |
| Max drawdown | $96,430 |
| Trades | 172 |
| Win rate | 59.3% |
| Profit factor | 1.52 |
| Average trade | $1,357.06 |
| Time in market | 81.97% |

Read the report in this order. First, the average trade of $1,357.06 against the cost of $30 per trade in commission and slippage: the costs are a small share of the average trade, so a doubling of slippage would not change the sign. That is the test behind whether algo trading is profitable for a retail trader, and a high-frequency version of the same rule would fail it. Second, time in market of 81.97 percent: the rule held a position on most days, so its equity curve partly rides the direction of the Nasdaq-100 over those years, and any serious judgment needs a comparison with simply holding the index. Third, the max drawdown of $96,430 against the net profit of $233,415: the ratio is a little under 2.4 to 1, and this is the number the search ranked candidates on.
Now the part that is easy to miss. This candidate was picked after the fact, as the best of 1,024 by return against drawdown. Picking the winner from a large set flatters it, because part of its result is the noise that happened to line up with this history. Bailey, Borwein, López de Prado and Zhu (2014) show that the expected inflation grows with the number of candidates compared on the same data. The box shows what a report looks like and how to read one. It does not show that an ATR rule, or a fair value gap, earned that money, and it is not a figure a reader can expect.
To turn the dollar figures into points: NQ is quoted at $20 per index point with a minimum tick of 0.25 points, so the average trade of $1,357.06 is about 68 index points. Exchanges can change contract values, so check the current figures on the exchange's contract page, or let the free futures contract calculator for tick and point values do the conversion for you.
Does SMC actually work?
No public study settles it either way, so treat each SMC rule like any other price rule and make it earn trust through the same checks. Reviews of technical trading rules in general find mixed results that depend heavily on the period, the market and how many rules were searched before the reported one was found (Park and Irwin, 2007). Order blocks and fair value gaps have not been examined in that literature under agreed definitions, partly because, as the sections above show, no agreed definition exists. The absence of evidence is not evidence against the patterns. It is a reason to run the test yourself, on your own bars, with the rule written in full.
The order of checks below is the same one any breakout or candlestick rule must pass. Stop at the first failure and discard the variant; do not adjust a setting and retry on the same data.
- Write the rule in full. Every setting from the earlier sections, plus the exit, the session and the bar size.
- Backtest with costs and next-bar fills. Commission and slippage on every trade, orders filled on the bar after the signal.
- Compare with a plain baseline. A baseline is the simplest rule that holds a position as often as yours: for a rule that is long most of the time, holding the contract; for a rule that trades returns to a zone, a plain buy at a fixed pullback from the recent high. If the baseline does as well, the pattern added nothing.
- Grade on out-of-sample data. Fix the settings on the earlier part of the history and run them unchanged on the later part. How much is enough is measured in trades, as explained in the guide to splitting in-sample and out-of-sample data.
- Run walk-forward and doubled slippage. Walk-forward analysis is a test that tunes settings on one window, runs them unchanged on the next, and repeats along the history. Doubling slippage shows whether the result depends on cheap fills.
- Test once on an untouched final block. The most recent months, never loaded into any earlier run, used exactly once.
Steps four to six are where most hand-drawn patterns fall over, because a chart trader sees the blocks that worked and forgets the ones that did not; the computer counts both. Setting the pass levels for walk-forward and out-of-sample before the search starts, as strategy validation in AlphaPrime requires with its thresholds, removes the temptation to move the goalposts after the curve is on screen, and stopping the later checks when an earlier one fails keeps the number of variants that reach the final block small.
On the question of the best technical indicators for a smart money strategy: the honest answer is that SMC uses none. The only indicator a rule writer normally adds is the ATR, and only to scale the size thresholds. Anything else you add is a filter, and each filter is one more setting to write down and one more way to fit the past.
The next step is small and concrete. Take the bullish fair value gap rule with its minimum gap size and fill rule, write all of its settings and an exit on one line, run it with your real commission and one tick of slippage on the bar size you actually watch, and read two numbers before anything else: the average trade after costs against the round-trip cost, and the result against a plain baseline that is in the market as often. If you want a route for the whole first month of this kind of work, the 30-day route to a first algo trading strategy lays out the order of steps.
Frequently asked questions
What is an order block in trading?
An order block is the zone of the last candle of the opposite colour before a strong move: the last down candle before a sharp rise, or the last up candle before a sharp fall. Traders who use it expect price to react when it returns to that zone. To test it, you must first write down which candle qualifies, how large the following move must be, which prices form the zone, what counts as a touch, and when the zone expires.
What is a fair value gap (FVG)?
A fair value gap is the price space a fast move left untraded across three candles. A bullish gap exists when the high of the first candle is below the low of the third; a bearish gap exists when the low of the first is above the high of the third. The gap size is the difference between those two prices. With a minimum size in ATR units and a fill rule, the pattern is fully mechanical and can be backtested on any bar data.
Is ICT the same as SMC?
No. ICT is an older and larger body of lessons from one trader, with a strong emphasis on named session windows around the London and New York opens. SMC is a simplified version that spread through online communities, usually without a required session filter, and it leans on structure terms such as break of structure and change of character. Both use order blocks and fair value gaps, but a rule written for one is not automatically the rule the other school means.
Does SMC actually work?
There is no public study that settles it, and the patterns have no agreed definition, so no single answer is possible. The useful approach is to write one exact variant, backtest it with costs and next-bar fills, compare it with a plain baseline that is in the market as often, grade it out-of-sample and with walk-forward, and test it once on an untouched recent block. A variant that passes all of that is worth trading small; one that fails any step is discarded, not adjusted.
References
- Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
- Park, C.-H., & Irwin, S. H. (2007). What Do We Know About the Profitability of Technical Analysis? Journal of Economic Surveys, 21(4), 786–826.
- Wilder, J. W. (1978). New Concepts in Technical Trading Systems. Trend Research.
- CME Group. E-mini Nasdaq-100 Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html

