Indicator · Pine Script v6 · On the chart

Advanced Order Blocks with Volume

by deepentropy

This script identifies and visualizes bullish and bearish order blocks on the price chart.

View on GitHub

GitHub stars13on the repository
Pine versionv6current
Lines of code91
Settings9inputs
LicenceMIT
Last update6 months ago29 Apr 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

91 lines of Pine Script v6 from examples/Advanced Order Blocks with Volume.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Advanced Order Blocks with Volume.pine
//@version=6
indicator("Advanced Order Blocks with Volume", overlay=true)

// User Inputs
var float CONSOLIDATION_THRESHOLD = input.float(0.1, "Consolidation Threshold %", minval=0.1, maxval=1.0, step=0.1)
var int LOOKBACK = input.int(2, "Lookback Period", minval=2, maxval=10)
var color BULL_COLOR = input.color(color.new(#06aa20, 70), "Bullish OB Color")
var color BULL_COLOR_TXT = input.color(color.rgb(48, 233, 79), "Bullish OB Color")
var color BEAR_COLOR = input.color(color.new(#f23645, 70), "Bearish OB Color")
var color BEAR_COLOR_TXT = input.color(color.rgb(255, 63, 63), "Bearish OB Color")
// Volume Analysis Inputs
var string VOL_CALC_METHOD = input.string("Relative", "Volume Calculation Method", options=["Simple", "Relative", "Weighted"])
var int VOL_LOOKBACK = input.int(20, "Volume Lookback Period", minval=5, maxval=100)
var float VOL_THRESHOLD = input.float(1.2, "Volume Threshold Multiplier", minval=1.0, maxval=5.0, step=0.1)

// Arrays to store order blocks and volumes
var bullish_obs = array.new<box>()
var bearish_obs = array.new<box>()
var bullish_volumes = array.new<float>()
var bearish_volumes = array.new<float>()

// Detect consolidation
is_consolidation(len) =>
    high_point = ta.highest(high, len)
    low_point = ta.lowest(low, len)
    rge = (high_point - low_point) / low_point * 100
    rge <= CONSOLIDATION_THRESHOLD

// Detect breakout
is_breakout() =>
    bull_break = close > open and (close - open) / open * 100 > CONSOLIDATION_THRESHOLD
    bear_break = close < open and (open - close) / open * 100 > CONSOLIDATION_THRESHOLD
    [bull_break, bear_break]

// Enhanced volume calculation function
get_ob_volume(len) =>
    float vol = 0.0

    if VOL_CALC_METHOD == "Simple"
        vol := math.avg(volume, volume[1])
    else if VOL_CALC_METHOD == "Relative"
        avg_vol = ta.sma(volume, len)
        vol := volume / avg_vol
    else // Weighted
        weight1 = 2.0
        weight2 = 1.0
        vol := (volume * weight1 + volume[1] * weight2) / (weight1 + weight2)

    // Apply volume threshold filter
    avg_volume = ta.sma(volume, VOL_LOOKBACK)
    significant_volume = volume > avg_volume * VOL_THRESHOLD

    [vol, significant_volume]

// Check for order block setup
[bull_break, bear_break] = is_breakout()
in_consolidation = is_consolidation(LOOKBACK)
[current_volume, is_significant] = get_ob_volume(VOL_LOOKBACK)

// Create new order blocks
if in_consolidation[1] and bull_break and is_significant
    box_obj = box.new(time[1], high[1], time, low[1], bgcolor=BULL_COLOR, text_halign = text.align_right, border_color=color.new(color.white, 100), extend=extend.right, xloc=xloc.bar_time, text="                               Vol: " + str.tostring(current_volume, format.volume) + (VOL_CALC_METHOD == "Relative" ? "x" : ""), text_size=size.small, text_color=BULL_COLOR_TXT)
    array.push(bullish_obs, box_obj)
    array.push(bullish_volumes, current_volume)

if in_consolidation[1] and bear_break and is_significant
    box_obj = box.new(time[1], high[1], time, low[1], bgcolor=BEAR_COLOR, text_halign = text.align_right, border_color=color.new(color.white, 100), extend=extend.right, xloc=xloc.bar_time, text="                               Vol: " + str.tostring(current_volume, format.volume) + (VOL_CALC_METHOD == "Relative" ? "x" : ""), text_size=size.small, text_color=BEAR_COLOR_TXT)
    array.push(bearish_obs, box_obj)
    array.push(bearish_volumes, current_volume)

// Check for mitigation
check_mitigation() =>
    if array.size(bullish_obs) > 0
        for i = array.size(bullish_obs) - 1 to 0
            box_obj = array.get(bullish_obs, i)
            box.set_right(box_obj,time)
            if low < box.get_bottom(box_obj)
                box.delete(box_obj)
                array.remove(bullish_obs, i)
                array.remove(bullish_volumes, i)

    if array.size(bearish_obs) > 0
        for i = array.size(bearish_obs) - 1 to 0
            box_obj = array.get(bearish_obs, i)
            box.set_right(box_obj,time)
            if high > box.get_top(box_obj)
                box.delete(box_obj)
                array.remove(bearish_obs, i)
                array.remove(bearish_volumes, i)

check_mitigation()

Overview

Advanced Order Blocks with Volume detects low-volatility consolidation ranges followed by breakout moves accompanied by high trading volume. Users can select between Simple, Relative, or Weighted volume calculation methods and configure threshold multipliers to filter out low-volume setups. Validated order blocks are rendered directly on the chart as extended colored boxes displaying volume metrics, aiding in locating supply and demand zones.

Details

Published by

deepentropy on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance, Volume, Breakout

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Consolidation Threshold %float0.1CONSOLIDATION_THRESHOLD
Lookback Periodint2LOOKBACK
Bullish OB Colorcolorcolor.new(#06aa20, 70)BULL_COLOR
Bullish OB Colorcolorcolor.rgb(48, 233, 79)BULL_COLOR_TXT
Bearish OB Colorcolorcolor.new(#f23645, 70)BEAR_COLOR
Bearish OB Colorcolorcolor.rgb(255, 63, 63)BEAR_COLOR_TXT
Volume Calculation MethodstringRelativeVOL_CALC_METHOD
Volume Lookback Periodint20VOL_LOOKBACK
Volume Threshold Multiplierfloat1.2VOL_THRESHOLD
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This indicator implements a Wyckoff method state machine that tracks accumulation, distribution, markup, and markdown regimes across phases A through E. It identifies structural events including springs, UTADs, SOS, SOW, LPS, LPSY, and climactic bars using ATR

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated yesterday · MIT GitHub repository of Modern Wyckoff State Machine Lite [WavesUnchained]

This indicator identifies dynamic support and resistance levels using pivot highs and lows. It plots resistance and support lines directly on the price chart once pivot points are confirmed. Additionally, it calculates a volume oscillator using 9-period and 26

Indicator v5 Support & resistanceSMC / ICT / price action
Updated 1 year ago · MPL-2.0 GitHub repository of Support & Resistance Levels with Break of Structure
2 stars

SMC + POC Signals identifies Smart Money Concepts structure elements including Break of Structure (BOS), Change of Character (CHoCH), Order Blocks, and Fair Value Gaps alongside a rolling Point of Control (POC) volume profile line. It marks potential long and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 3 weeks ago · None stated GitHub repository of SMC + POC Signals [factor-lab]
1 stars

This indicator identifies bullish Change of Character (CHoCH) structure shifts directly on the price chart using pivot swing points. It tracks swing highs and lows governed by configurable left and right lengths and maximum swing age. The script highlights CHo

Indicator v6 SMC / ICT / price actionBreakout
Updated 2 days ago · None stated GitHub repository of REV Ladder (Best Bullish CHoCH)

SMC+OB+FVG_PH

by mydcc
1 stars

This indicator plots smart money concept structures directly on the price chart. It detects and visualizes market structure elements including change of character, break of structure, swing points, inducements, and liquidity sweeps. Additionally, it identifies

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated today · Custom licence GitHub repository of SMC+OB+FVG_PH

Moon Dev GEX Sweep & CVD

by moondevonyt
92 stars

The indicator detects liquidity sweeps across key price levels and calculates a cumulative volume delta proxy. It uses pivot high and low lookbacks to identify swing points, marking sweeps when price breaks beyond a level and quickly closes back inside. Featur

Indicator v5 Support & resistanceSMC / ICT / price action
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Sweep & CVD

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers