SML Dual Market
Instant download · 7-day refunds on every product — see the refund policy · Veteran-owned small business
Order Blocks Indicator — Free Pine Script v6 for TradingViewOrder Blocks Indicator — Free Pine Script v6 for TradingView — ZIP bundle cover

Order Blocks Indicator — Free Pine Script v6 for TradingView

Free
Get it free
Free · instant download on claim · no account · signed receipt — how buying works →
Sold byScript Master Labs LLC (SDVOSB · UEI G24VZA4RLMK3 · CAGE 21U51)
File checkedWe test-download every product before it's listed (last checked Dec 4, 2026).
UpdatedDec 4, 2026
No account needed. Your download link appears right after checkout — bookmark it.
You get exactly this
free-order-blocks-indicator.zip — complete Pine Script v6 source + install README + free license (free edition)
What's inside
ZIP — Pine Script v6 source (.pine), install README, free license
  • order-blocks-indicator.pine — the complete Pine Script v6 source
  • README-FIRST.md — what it does and how to install it
  • FREE-LICENSE.md — the free-edition license terms
Delivered as one download, the moment you claim it — no payment, no account.

About this product

Order Blocks Indicator is a free Pine Script v6 indicator by Script Master Labs. It marks order-block candidates — the candle range a displacement move confirmed — and tracks their mitigation. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.

What it computes, in its own terms: it order-block candidates under one explicit mechanical definition: a bullish block is a down candle followed within 5 bars by a close above its high on a displacement bar (range at least 1.0 × ATR), and the block is that candle's high–low range; the bearish block is the mirror image. A block is mitigated when price closes through its far edge. 'Order block' is a charting concept, not a verified record of any institution's orders; nothing on the chart shows who traded or why.

How to use it

Open TradingView's Pine Editor, create a new blank script, paste the source, save, and click Add to chart. Adjust the inputs from the gear icon. The full source is printed on this page below, and the free download carries the same source file with an install README and the free-edition license.

Free edition vs paid edition

The script file is the complete indicator — the same Pine Script v6 source sold in the paid edition (https://dual.scriptmasterlabs.com/product/order-blocks-indicator, $19 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews. Nothing in the script is held back from the free edition.

More free tools — free Pine Script v6 indicators and strategies, free trading calculators and a free x402 pre-payment trust check — are collected on the Free Tools hub. Educational software, not financial advice: it measures and draws a stated rule; it does not predict price and shows no win rate.

The complete Pine Script v6 source — free, on this page

Order Blocks Indicator is a free Pine Script v6 indicator by Script Master Labs. It marks order-block candidates — the candle range a displacement move confirmed — and tracks their mitigation. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.

Copy it into TradingView's Pine Editor (new blank indicator → paste → Save → Add to chart), or claim the free download above for the same source as a file with an install README. Educational software, not financial advice.

// © 2026 Script Master Labs LLC — Order Blocks Indicator for TradingView
// Research-based, original SML engineering. This indicator MARKS order-block
// CANDIDATES under one explicit, mechanical definition (below). "Order block"
// is a charting concept, not a verified record of any institution's orders;
// nothing on the chart shows who traded or why.
//@version=6
indicator("SML Order Blocks Indicator", shorttitle = "SML Order Blocks", overlay = true, max_boxes_count = 500, max_labels_count = 500)

// ── The mechanical definition used by this indicator ────────────────────────
// Bullish order block: a DOWN candle (close < open) that is followed, within
// the next `swingLen` bars, by a close above that candle's high AND a
// displacement move (the confirming candle's range is at least
// `dispMult` × ATR 14). The block is the down candle's high–low range.
// Bearish order block: the mirror image (up candle, later close below its
// low, with displacement). A block is mitigated when price closes through
// its far edge (below the low for bullish, above the high for bearish).

// ── Inputs ──────────────────────────────────────────────────────────────────
swingLen   = input.int(5, "Confirmation window (bars after candidate candle)", minval = 1, maxval = 20)
dispMult   = input.float(1.0, "Displacement: confirming range ≥ this × ATR 14", minval = 0.0, step = 0.1)
maxBlocks  = input.int(10, "Maximum blocks kept per direction", minval = 1, maxval = 50)
extendBars = input.int(60, "Extend each block this many bars right", minval = 1, maxval = 500)
showMitigated = input.bool(false, "Keep mitigated blocks visible (faded)")
bullColor  = input.color(color.new(color.teal, 82), "Bullish block fill")
bearColor  = input.color(color.new(color.red, 82), "Bearish block fill")

atr14 = ta.atr(14)

// Candidate candles, evaluated with a delay of up to swingLen bars: we keep
// the most recent unconfirmed down-candle and up-candle as candidates.
var float candDownHigh = na
var float candDownLow  = na
var int   candDownBar  = na
var int   candDownAge  = 0
var float candUpHigh   = na
var float candUpLow    = na
var int   candUpBar    = na
var int   candUpAge    = 0

var box[]  bullBoxes = array.new_box()
var float[] bullHighs = array.new_float()
var float[] bullLows  = array.new_float()
var box[]  bearBoxes = array.new_box()
var float[] bearHighs = array.new_float()
var float[] bearLows  = array.new_float()

f_trim(_boxes, _highs, _lows) =>
    while array.size(_boxes) > maxBlocks
        box.delete(array.shift(_boxes))
        array.shift(_highs)
        array.shift(_lows)

var bool newBull = false
var bool newBear = false
newBull := false
newBear := false

// Register new candidates (a down candle becomes the bullish candidate).
if close < open
    candDownHigh := high
    candDownLow  := low
    candDownBar  := bar_index
    candDownAge  := 0
if close > open
    candUpHigh := high
    candUpLow  := low
    candUpBar  := bar_index
    candUpAge  := 0

// Confirm or expire candidates.
if not na(candDownBar) and bar_index > candDownBar
    candDownAge += 1
    displaced = (high - low) >= dispMult * atr14
    if close > candDownHigh and displaced
        b = box.new(candDownBar, candDownHigh, bar_index + extendBars, candDownLow, border_color = color.new(color.teal, 50), bgcolor = bullColor)
        array.push(bullBoxes, b)
        array.push(bullHighs, candDownHigh)
        array.push(bullLows, candDownLow)
        f_trim(bullBoxes, bullHighs, bullLows)
        newBull := true
        candDownBar := na
    else if candDownAge > swingLen
        candDownBar := na

if not na(candUpBar) and bar_index > candUpBar
    candUpAge += 1
    displaced = (high - low) >= dispMult * atr14
    if close < candUpLow and displaced
        b = box.new(candUpBar, candUpHigh, bar_index + extendBars, candUpLow, border_color = color.new(color.red, 50), bgcolor = bearColor)
        array.push(bearBoxes, b)
        array.push(bearHighs, candUpHigh)
        array.push(bearLows, candUpLow)
        f_trim(bearBoxes, bearHighs, bearLows)
        newBear := true
        candUpBar := na
    else if candUpAge > swingLen
        candUpBar := na

// ── Mitigation ──────────────────────────────────────────────────────────────
f_mitigate(_boxes, _highs, _lows, _isBull) =>
    i = array.size(_boxes) - 1
    while i >= 0
        hit = _isBull ? close < array.get(_lows, i) : close > array.get(_highs, i)
        if hit
            if showMitigated
                box.set_bgcolor(array.get(_boxes, i), color.new(color.gray, 92))
                box.set_right(array.get(_boxes, i), bar_index)
            else
                box.delete(array.get(_boxes, i))
            array.remove(_boxes, i)
            array.remove(_highs, i)
            array.remove(_lows, i)
        i -= 1

if barstate.isconfirmed
    f_mitigate(bullBoxes, bullHighs, bullLows, true)
    f_mitigate(bearBoxes, bearHighs, bearLows, false)

alertcondition(newBull, title = "Bullish order block confirmed", message = "Bullish order-block candidate confirmed under the indicator's mechanical definition on {{exchange}}:{{ticker}} ({{interval}}).")
alertcondition(newBear, title = "Bearish order block confirmed", message = "Bearish order-block candidate confirmed under the indicator's mechanical definition on {{exchange}}:{{ticker}} ({{interval}}).")
Frequently paired

Questions about this product

Is there a free Pine Script for order blocks on TradingView?

Yes. Script Master Labs publishes this Order Blocks Indicator as a free Pine Script v6 download on SML Dual Market (https://dual.scriptmasterlabs.com/product/free-order-blocks-indicator). The complete source is printed in full on the product page and in the free download — no payment, no account, no subscription.

How do I use the Order Blocks Indicator?

Open TradingView's Pine Editor, create a new blank script, paste the source, click Save, then Add to chart. Adjust the inputs from the gear icon. TradingView's first-steps page shows where the editor opens: https://tradingview.com/pine-script-docs/primer/first-steps

Does it work on TradingView's free plan?

Yes. Paste the source into TradingView's Pine Editor and add it to your chart; the free plan runs custom indicators.

Is the free edition the complete script?

Yes — the same Pine Script v6 source file sold in the paid edition ($19 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews; nothing in the script itself is held back.