◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Strategies / Order Block Strategy
Concept breakdown

Order Block Strategy

An "order block" is a price-action concept popularised in the smart-money / ICT trading community. It refers to the last opposing candle (or cluster) right before an impulsive, structure-breaking move — for example the last down-candle before a sharp rally — which traders treat as a reference zone where price may react if it returns. This page explains how traders define, mark, and use order blocks for entries, exits, and risk, and gives a valid Pine Script v6 example. Because the real concept relies on discretionary structure reading and zone "mitigation," it does not reduce to one mechanical strategy, so the script below is an illustrative detection/marker, clearly labelled as such. This is educational only: nothing here predicts price, no profit or win-rate is implied, and trading carries the risk of loss. Terms like "order block," "smart money," and "ICT" are referenced descriptively; any related trademarks belong to their respective owners. To turn your own order-block rules into validated Pine v6 and check them for look-ahead bias and repainting, run them through the ForexCodes Strategy Validator (try it free).

How it works

An order block is not an indicator with a formula — it is a way traders label a specific candle on the chart after the fact. The common definition is: the last candle of the opposite colour immediately before an impulsive move that breaks recent market structure. A bullish order block is the last down-candle before price rallies up and takes out a prior swing high; a bearish order block is the last up-candle before price drops and breaks a prior swing low. The body and/or the full high-low range of that candle is then treated as a "zone."

The reasoning traders attach to it (a narrative, not a mechanism the market is obliged to follow) is that this candle marks an area where a large amount of buying or selling stepped in to start the move. If price later returns to that zone — referred to as the zone being "mitigated" or "tested" — some traders watch for a reaction in the original direction. None of this is predictive; many marked zones are simply traded straight through.

Three pieces have to be defined to make the idea concrete: (1) what counts as the impulsive move and structure break (commonly a close beyond a recent swing high or low, sometimes called a break of structure, BOS); (2) which candle before that move is the order block (typically the last opposite-colour candle); and (3) what counts as a valid "test" of the zone and what would invalidate it (usually a close all the way through the zone against the intended direction). Different traders draw the zone differently (body only vs. full wick), use different swing-detection settings, and add filters such as requiring an unfilled Fair Value Gap nearby or trading only with a higher-timeframe bias.

Because steps (1)–(3) involve choices and discretion — especially deciding when a zone is "fresh," when it has been "mitigated," and when to act on a return — the concept does not collapse into a single mechanical entry rule the way a moving-average crossover does. That is why the script below is an illustrative detection/marker: it locates candidate order blocks from a mechanical structure-break rule and draws them so you can study the idea on a chart, rather than firing automatic trades. It also makes the concept's main hidden danger visible: order blocks are defined by looking back from a confirmed structure break, so it is very easy to code them in a way that repaints or peeks at future bars.

Entry rules

Exit rules

Risk notes

Pine v6 example

//@version=6
// Order Block — ILLUSTRATIVE DETECTION / MARKER (educational only).
// The order-block concept relies on discretionary structure reading and zone
// "mitigation", so it does NOT reduce to one mechanical strategy. This script
// only DETECTS and DRAWS candidate order blocks from a simple structure-break
// rule so you can study the idea on a chart. It does not place trades and is
// not predictive. Backtests/visuals are illustrative; past behaviour does not
// indicate future behaviour. Trading involves the risk of loss.
indicator("Order Block (illustrative marker)", overlay = true, max_boxes_count = 60, max_labels_count = 60)

// --- Inputs ---
pivotLen   = input.int(10, "Swing lookback (pivot length)", minval = 2)
searchBack = input.int(50, "Max bars to search back for the block candle", minval = 1, maxval = 300)
useBody    = input.bool(true, "Zone = candle body (off = full high/low range)")
showBoxes  = input.bool(true, "Draw order-block zones")

// --- Structure: confirmed swing highs/lows ---
// ta.pivothigh/low return a value only once the pivot is fully confirmed
// (pivotLen bars after it formed), so they do not repaint on the live bar.
// The returned value already IS the pivot price.
ph = ta.pivothigh(high, pivotLen, pivotLen)
pl = ta.pivotlow(low, pivotLen, pivotLen)

// Track the most recent confirmed swing levels.
var float lastSwingHigh = na
var float lastSwingLow  = na
if not na(ph)
    lastSwingHigh := ph
if not na(pl)
    lastSwingLow := pl

// --- Break of structure on the CURRENT closed bar ---
bullBreak = not na(lastSwingHigh) and close > lastSwingHigh
bearBreak = not na(lastSwingLow) and close < lastSwingLow

// --- Find the order-block candle: last opposite-colour candle before the move ---
// Search back from the previous bar for the most recent qualifying candle.
// Returns the bar offset (>=1), or na if none found within searchBack bars.
findBlock(bool isBull) =>
    int idx = na
    for i = 1 to searchBack
        bool bodyDown = close[i] < open[i]   // down candle
        bool bodyUp   = close[i] > open[i]   // up candle
        if (isBull and bodyDown) or (not isBull and bodyUp)
            idx := i
            break
    idx

// Act only on confirmed (closed) bars to avoid acting on a signal that
// could still change before the bar closes.
if bullBreak and barstate.isconfirmed
    int i = findBlock(true)
    if not na(i)
        float top = useBody ? math.max(open[i], close[i]) : high[i]
        float bot = useBody ? math.min(open[i], close[i]) : low[i]
        if showBoxes
            box.new(bar_index[i], top, bar_index, bot,
                 border_color = color.new(color.teal, 0),
                 bgcolor = color.new(color.teal, 85))
        label.new(bar_index[i], bot, "Bull OB", style = label.style_label_up,
             color = color.new(color.teal, 20), textcolor = color.white, size = size.tiny)

if bearBreak and barstate.isconfirmed
    int i = findBlock(false)
    if not na(i)
        float top = useBody ? math.max(open[i], close[i]) : high[i]
        float bot = useBody ? math.min(open[i], close[i]) : low[i]
        if showBoxes
            box.new(bar_index[i], top, bar_index, bot,
                 border_color = color.new(color.maroon, 0),
                 bgcolor = color.new(color.maroon, 85))
        label.new(bar_index[i], top, "Bear OB", style = label.style_label_down,
             color = color.new(color.maroon, 20), textcolor = color.white, size = size.tiny)

// Markers on the bar where a structure break confirmed a candidate block.
plotshape(bullBreak and barstate.isconfirmed, title = "Bull break",
     style = shape.triangleup, location = location.belowbar,
     color = color.new(color.teal, 0), size = size.tiny)
plotshape(bearBreak and barstate.isconfirmed, title = "Bear break",
     style = shape.triangledown, location = location.abovebar,
     color = color.new(color.maroon, 0), size = size.tiny)

// Educational tool only. Not financial advice and not predictive. Validate any
// order-block strategy for look-ahead bias and repainting with the ForexCodes
// Strategy Validator before reading anything into a backtest.

Pitfalls

FAQ

What exactly is an order block, in plain terms?

It is a label traders put on a specific candle: the last opposite-colour candle right before an impulsive move that breaks recent market structure. The last down-candle before a strong rally is a bullish order block; the last up-candle before a sharp drop is a bearish one. The candle's body or full range is then treated as a zone price may react to if it returns. It is a way of marking an area of interest, not a formula and not a prediction.

Why is the Pine example a detection/marker instead of a full buy/sell strategy?

Because the real concept is partly discretionary. Deciding what counts as the impulsive move, which candle is the block, when a zone is 'fresh' versus 'mitigated', and what counts as a valid test are all judgement calls that different traders make differently. Forcing all of that into one mechanical strategy would misrepresent the idea, so the script mechanically detects candidate order blocks from a clear structure-break rule and draws them for study, leaving entry timing and exits to you. That is also the honest way to present it.

Do order blocks repaint or look ahead?

They can, very easily, if coded carelessly. An order block is identified by looking back from a confirmed structure break, so a script can accidentally use information that was not available when the bar was live, or mark and un-mark zones intrabar. Anchoring detection to confirmed swing pivots and acting only on closed bars (barstate.isconfirmed) avoids the worst of it. This is exactly the class of bug the ForexCodes Strategy Validator is built to catch — paste your order-block script in (or try it free) to confirm it is clean before you read anything into a backtest.

Is an order block strategy profitable or high win-rate?

We can't and won't make profit or win-rate claims. Nothing about order blocks is predictive — marked zones are frequently traded straight through — and trading carries the risk of loss. It is a framework for organising observations about structure and prior activity. How any specific rule set behaves depends on the instrument, timeframe, costs, and risk management, and even a clean backtest is illustrative only because past behaviour does not indicate future results.

Educational & software only — not financial advice, not a recommendation to trade. Backtests are illustrative; past performance does not predict future results. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro