Indicator · Pine Script v6 · On the chart

Institutional Order Flow Strength Classifier [LuxAlgo]

by theonetrade· code credited to LuxAlgo

This indicator detects bullish and bearish order blocks based on pivot points and market structure breaks.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code211
Settings8inputs
LicenceMIT
Last update2 weeks ago8 Nov 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

211 lines of Pine Script v6 from assets/indicator/bit-exact/institutional_order_flow_strength_classifier_luxalgo_gesy3qTZ.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

institutional_order_flow_strength_classifier_luxalgo_gesy3qTZ.pine
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=6
indicator("Institutional Order Flow Strength Classifier [LuxAlgo]", "LuxAlgo - Institutional Order Flow Strength Classifier", overlay = true, max_boxes_count = 100, max_labels_count = 100)

//---------------------------------------------------------------------------------------------------------------------}
// Constants & Inputs
//---------------------------------------------------------------------------------------------------------------------{
color BULL_COLOR = #089981
color BEAR_COLOR = #f23645
color TEXT_COLOR = chart.fg_color

string OB_GROUP   = "Order Block Settings"
int pivotLenInput = input.int(5, "Pivot Lookback", minval = 2, group = OB_GROUP)
int maxOBsInput   = input.int(5, "Max Unmitigated OBs", minval = 1, maxval = 50, group = OB_GROUP)

string VIS_GROUP   = "Visualization"
color bullColorInput = input.color(color.new(BULL_COLOR, 80), "Bullish OB Color", group = VIS_GROUP)
color bearColorInput = input.color(color.new(BEAR_COLOR, 80), "Bearish OB Color", group = VIS_GROUP)
bool hideOverlappedInput = input.bool(true, "Hide Overlapped Zones", group = VIS_GROUP)
bool showLabelsInput = input.bool(true, "Show Strength Labels", group = VIS_GROUP)
bool showStrongestInput = input.bool(true, "Show Strongest OB Plot", group = VIS_GROUP)
int bufferSizeInput = input.int(5, "Strongest OB Buffer Size", minval = 1, maxval = 100, group = VIS_GROUP)

//---------------------------------------------------------------------------------------------------------------------}
// Types & Methods
//---------------------------------------------------------------------------------------------------------------------{
type OrderBlock
    float top
    float bottom
    int   startTime
    float strength
    bool  isBullish
    box   boxId
    label labelId
    bool  mitigated

//---------------------------------------------------------------------------------------------------------------------}
// Functions
//---------------------------------------------------------------------------------------------------------------------{
// Calculate OB Strength using displacement and volume factors
calculateStrength(float obRange, float breakoutDist, float relVol) =>
    float dispFactor = math.min(breakoutDist / (obRange * 5), 1.0)
    float volFactor = math.min(relVol / 2.0, 1.0)
    float score = (dispFactor * 0.6 + volFactor * 0.4) * 100
    math.round(score, 1)

//---------------------------------------------------------------------------------------------------------------------}
// Main Logic
//---------------------------------------------------------------------------------------------------------------------{
var obArray = array.new<OrderBlock>()
float volSMA = ta.sma(volume, 20)

// Pivot Detection
float hi = ta.pivothigh(pivotLenInput, pivotLenInput)
float lo = ta.pivotlow(pivotLenInput, pivotLenInput)

var float lastHi = na
var float lastLo = na
var int lastHiIdx = na
var int lastLoIdx = na

if not na(hi)
    lastHi := hi
    lastHiIdx := bar_index - pivotLenInput
if not na(lo)
    lastLo := lo
    lastLoIdx := bar_index - pivotLenInput

// Market Structure Break (BOS) detection
bool bullBOS = ta.crossover(close, lastHi)
bool bearBOS = ta.crossunder(close, lastLo)

if bullBOS or bearBOS
    int searchLen = bar_index - (bullBOS ? lastHiIdx : lastLoIdx)
    float obTop = na
    float obBtm = na
    int obIdx = na
    float obVol = na
    
    if bullBOS
        float minLow = na
        for i = 1 to searchLen
            if close[i] < open[i]
                if na(minLow) or low[i] < minLow
                    minLow := low[i]
                    obTop := high[i]
                    obBtm := low[i]
                    obIdx := i
                    obVol := volume[i]
        lastHi := na 
    else
        float maxHigh = na
        for i = 1 to searchLen
            if close[i] > open[i]
                if na(maxHigh) or high[i] > maxHigh
                    maxHigh := high[i]
                    obTop := high[i]
                    obBtm := low[i]
                    obIdx := i
                    obVol := volume[i]
        lastLo := na
        
    if not na(obIdx)
        float obHeight = obTop - obBtm
        float breakoutDist = bullBOS ? (close - obTop) : (obBtm - close)
        float avgVol = volSMA[obIdx]
        float strength = calculateStrength(obHeight, breakoutDist, obVol / avgVol)
        
        OrderBlock newOB = OrderBlock.new(obTop, obBtm, time[obIdx], strength, bullBOS, na, na, false)
        array.unshift(obArray, newOB)

//---------------------------------------------------------------------------------------------------------------------}
// Mitigation, Strongest Tracking & Array Management
//---------------------------------------------------------------------------------------------------------------------{
// 1. Mitigation Check (Every Bar)
if array.size(obArray) > 0
    for i = 0 to array.size(obArray) - 1
        OrderBlock ob = array.get(obArray, i)
        if not ob.mitigated
            bool isMitigated = ob.isBullish ? low < ob.bottom : high > ob.top
            if isMitigated
                ob.mitigated := true

// 2. Strongest OB tracking within buffer
float strongestTop = na
float strongestBottom = na
float strongestAvgPrice = na
bool  strongestIsBullish = false
float maxStrength = -1.0

if array.size(obArray) > 0
    int checkedCount = 0
    for i = 0 to array.size(obArray) - 1
        OrderBlock ob = array.get(obArray, i)
        if not ob.mitigated
            if ob.strength > maxStrength
                maxStrength := ob.strength
                strongestTop := ob.top
                strongestBottom := ob.bottom
                strongestAvgPrice := (ob.top + ob.bottom) / 2
                strongestIsBullish := ob.isBullish
            
            checkedCount += 1
            if checkedCount >= bufferSizeInput
                break

// Plot strongest OB zone with directional color and clear cut on change
color plotCol = na(strongestAvgPrice) ? na : (strongestIsBullish ? bullColorInput : bearColorInput)
bool  hasChanged = strongestAvgPrice != strongestAvgPrice[1]

plotTop = plot(showStrongestInput ? strongestTop : na, "Strongest OB Top", color = hasChanged ? na : color.new(plotCol, 70))
plotBtm = plot(showStrongestInput ? strongestBottom : na, "Strongest OB Bottom", color = hasChanged ? na : color.new(plotCol, 70))
fill(plotTop, plotBtm, hasChanged ? na : color.new(plotCol, 90), "Strongest OB Zone Fill")

plot(showStrongestInput ? strongestAvgPrice : na, "Strongest OB Median", color = hasChanged ? na : color.new(plotCol, 40), linewidth = 2)

//---------------------------------------------------------------------------------------------------------------------}
// 3. Visual Management (Last Bar)
if barstate.islast
    int activeCount = 0
    var occupiedTops = array.new_float(0)
    var occupiedBtms = array.new_float(0)
    array.clear(occupiedTops)
    array.clear(occupiedBtms)
    
    if array.size(obArray) > 0
        for i = 0 to array.size(obArray) - 1
            OrderBlock ob = array.get(obArray, i)
            
            bool isOverlapped = false
            if not ob.mitigated and hideOverlappedInput and array.size(occupiedTops) > 0
                for j = 0 to array.size(occupiedTops) - 1
                    float otherTop = array.get(occupiedTops, j)
                    float otherBtm = array.get(occupiedBtms, j)
                    if (ob.top <= otherTop and ob.top >= otherBtm) or (ob.bottom <= otherTop and ob.bottom >= otherBtm) or (ob.top >= otherTop and ob.bottom <= otherBtm)
                        isOverlapped := true
                        break

            if not ob.mitigated and not isOverlapped and activeCount < maxOBsInput
                activeCount += 1
                array.push(occupiedTops, ob.top)
                array.push(occupiedBtms, ob.bottom)
                
                color obCol = ob.isBullish ? bullColorInput : bearColorInput
                color labelCol = ob.isBullish ? BULL_COLOR : BEAR_COLOR

                if na(ob.boxId)
                    ob.boxId := box.new(ob.startTime, ob.top, time, ob.bottom, bgcolor = obCol, border_color = obCol, border_style = line.style_dashed, xloc = xloc.bar_time)
                
                if showLabelsInput
                    if na(ob.labelId)
                        ob.labelId := label.new(time, (ob.top + ob.bottom) / 2, text = str.format("{0}%", ob.strength), style = label.style_label_left, textcolor = labelCol, color = #00000000, size = size.small, textalign = text.align_center, xloc = xloc.bar_time)
            else
                if not na(ob.boxId)
                    box.delete(ob.boxId)
                    ob.boxId := na
                if not na(ob.labelId)
                    label.delete(ob.labelId)
                    ob.labelId := na

// 4. Memory management (Every bar)
if array.size(obArray) > 100
    for i = array.size(obArray) - 1 to 0
        OrderBlock ob = array.get(obArray, i)
        if ob.mitigated and array.size(obArray) > 50
            array.remove(obArray, i)
        else if array.size(obArray) > 100
            array.pop(obArray)

//---------------------------------------------------------------------------------------------------------------------}

Overview

Institutional Order Flow Strength Classifier [LuxAlgo] evaluates order flow strength using a composite score calculated from price displacement relative to the order block range and relative volume. The indicator plots unmitigated order block zones directly on the price chart alongside optional strength labels and highlights the strongest zone. Settings allow users to adjust pivot lookback length, maximum visible unmitigated zones, strength display options, and zone filtering.

Details

Published by

theonetrade on GitHub

Code credit

LuxAlgo, as written in the script's header

Draws

On the price chart

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.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Pivot Lookbackint5pivotLenInput
Max Unmitigated OBsint5maxOBsInput
Bullish OB Colorcolorcolor.new(BULL_COLOR, 80)bullColorInput
Bearish OB Colorcolorcolor.new(BEAR_COLOR, 80)bearColorInput
Hide Overlapped ZonesbooltruehideOverlappedInput
Show Strength LabelsbooltrueshowLabelsInput
Show Strongest OB PlotbooltrueshowStrongestInput
Strongest OB Buffer Sizeint5bufferSizeInput
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

Moon Dev GEX Sweep & CVD

by moondevonyt
98 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 2 months ago · Custom licence GitHub repository of Moon Dev GEX Sweep & CVD

Order Flow Strategy (OFS)

by roan-maverick
69 stars

The Order Flow Strategy is a chart overlay indicator based on auction market theory and order flow concepts. It evaluates higher-timeframe value structure across custom timeframes alongside value area profiles (VAH, POC, VAL) and Fibonacci discount or premium

Indicator v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 10 days ago · Custom licence GitHub repository of Order Flow Strategy (OFS)

Calculates higher-timeframe volume profiles to identify Value Area High (VAH), Value Area Low (VAL), and Point of Control (POC) levels directly on the price chart. It flags potential reversal setups and Change in State of Delivery (CISD) patterns relative to v

Indicator v6 VolumeSupport & resistance
Updated 3 months ago · None stated GitHub repository of CandelaCharts - Value Area Reversals

Copilot

by milocaetano
48 stars

Copilot is an order flow range-reversal indicator designed to overlay trading setups directly on the price chart. It evaluates four criteria: market context (sideways vs trending regime based on ATR height), structure (double top or double bottom retests), abs

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 4 weeks ago · MIT GitHub repository of Copilot

Supply and Demand Visible Range identifies supply, demand, and equilibrium zones across the visible chart range. It accumulates high, low, and volume data starting from the leftmost visible bar, optionally requesting lower timeframe intrabar data for finer res

Indicator v5 Support & resistanceVolume Repaints
Updated 3 months ago · AGPL-3.0 GitHub repository of Supply and Demand Visible Range [LuxAlgo]
13 stars

This script identifies and visualizes bullish and bearish order blocks on the price chart. It detects low-volatility consolidation ranges followed by breakout moves accompanied by high trading volume. Users can select between Simple, Relative, or Weighted volu

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of Advanced Order Blocks with Volume

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers