Indicator · Pine Script v5 · On the chart

Jawaun's Advanced Order Block Finder

by jawauntb

This indicator identifies and plots bullish and bearish order blocks directly on the price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code113
Settings8inputs
LicenceGPL-3.0
Last update2 years ago22 May 2024

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

113 lines of Pine Script v5 from order-finder.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

order-finder.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jawauntb

//@version=5
indicator("Jawaun's Advanced Order Block Finder", overlay = true, max_labels_count = 500, max_lines_count = 500)


// Inputs
colors = input.string("LIGHT", "Color Scheme", options = ["DARK", "LIGHT"])
periods = input.int(7, "Relevant Periods to identify OB", minval = 1)
threshold = input.float(0.0, "Min. Percent move for valid OB", step = 0.1)
bull_channels = input.int(10, "Number of Bullish Channels to show", minval = 1)
bear_channels = input.int(10, "Number of Bearish Channels to show", minval = 1)
show_labels = input(true, "Show Labels")
show_mid_labels = input(true, "Show Mid Labels")
extend_lines = input(true, "Extend Lines")

// Color Scheme
bullcolor = colors == "DARK" ? color.white : color.green
bearcolor = colors == "DARK" ? color.blue : color.red
transparencyValue = 70

// Functions
percentChange(price1, price2) =>
    (price1 - price2) / price2 * 100

isValidOB(ob_period, threshold) =>
    percentChange(close[ob_period], close[1]) >= threshold or percentChange(close[1], close[ob_period]) >= threshold

isBullishOB(periods) =>
    close[periods + 1] < open[periods + 1] and ta.rising(close, periods)

isBearishOB(periods) =>
    close[periods + 1] > open[periods + 1] and ta.falling(close, periods)

// Order Block Identification
ob_period = periods + 1
validOB = isValidOB(ob_period, threshold)
bullishOB = validOB and isBullishOB(periods)
bearishOB = validOB and isBearishOB(periods)

// Order Block Levels
OB_bull_high = bullishOB ? high[ob_period] : na
OB_bull_low = bullishOB ? low[ob_period] : na
OB_bull_mid = bullishOB ? (OB_bull_high + OB_bull_low) / 2 : na
OB_bear_high = bearishOB ? high[ob_period] : na
OB_bear_low = bearishOB ? low[ob_period] : na
OB_bear_mid = bearishOB ? (OB_bear_high + OB_bear_low) / 2 : na

// Plotting
var bull_line_high = array.new_line()
var bull_line_low = array.new_line()
var bear_line_high = array.new_line()
var bear_line_low = array.new_line()
var bull_label = array.new_label()
var bear_label = array.new_label()
var bull_mid_label = array.new_label()
var bear_mid_label = array.new_label()

if bullishOB
    line1 = line.new(bar_index[ob_period], OB_bull_high, bar_index + 1, OB_bull_high, color = bullcolor, width = 2, style = line.style_solid)
    line2 = line.new(bar_index[ob_period], OB_bull_low, bar_index + 1, OB_bull_low, color = bullcolor, width = 2, style = line.style_solid)
    array.unshift(bull_line_high, line1)
    array.unshift(bull_line_low, line2)

    if extend_lines
        line.set_extend(line1, extend.right)
        line.set_extend(line2, extend.right)

    if show_mid_labels
        mid_label = label.new(bar_index[ob_period], OB_bull_mid, "BullOB Mid", color = color.new(bullcolor, transparencyValue), style = label.style_label_center, textcolor = color.white, size = size.small)
        array.unshift(bull_mid_label, mid_label)

    if show_labels
        label1 = label.new(bar_index[ob_period], OB_bull_high, "BullOB High", color = color.new(bullcolor, transparencyValue), style = label.style_label_down, textcolor = color.white, size = size.small)
        label2 = label.new(bar_index[ob_period], OB_bull_low, "BullOB Low", color = color.new(bullcolor, transparencyValue), style = label.style_label_up, textcolor = color.white, size = size.small)
        array.unshift(bull_label, label1)
        array.unshift(bull_label, label2)

if bearishOB
    line3 = line.new(bar_index[ob_period], OB_bear_high, bar_index + 1, OB_bear_high, color = bearcolor, width = 2, style = line.style_solid)
    line4 = line.new(bar_index[ob_period], OB_bear_low, bar_index + 1, OB_bear_low, color = bearcolor, width = 2, style = line.style_solid)
    array.unshift(bear_line_high, line3)
    array.unshift(bear_line_low, line4)

    if extend_lines
        line.set_extend(line3, extend.right)
        line.set_extend(line4, extend.right)

    if show_mid_labels
        mid_label = label.new(bar_index[ob_period], OB_bear_mid, "BearOB Mid", color = color.new(bearcolor, transparencyValue), style = label.style_label_center, textcolor = color.white, size = size.small)
        array.unshift(bear_mid_label, mid_label)

    if show_labels
        label3 = label.new(bar_index[ob_period], OB_bear_high, "BearOB High", color = color.new(bearcolor, transparencyValue), style = label.style_label_down, textcolor = color.white, size = size.small)
        label4 = label.new(bar_index[ob_period], OB_bear_low, "BearOB Low", color = color.new(bearcolor, transparencyValue), style = label.style_label_up, textcolor = color.white, size = size.small)
        array.unshift(bear_label, label3)
        array.unshift(bear_label, label4)

// Cleanup
if array.size(bull_line_high) > bull_channels
    line.delete(array.pop(bull_line_high))
    line.delete(array.pop(bull_line_low))
    label.delete(array.pop(bull_label))
    label.delete(array.pop(bull_label))
    label.delete(array.pop(bull_mid_label))

if array.size(bear_line_high) > bear_channels
    line.delete(array.pop(bear_line_high))
    line.delete(array.pop(bear_line_low))
    label.delete(array.pop(bear_label))
    label.delete(array.pop(bear_label))
    label.delete(array.pop(bear_mid_label))

Overview

Jawaun's Advanced Order Block Finder defines an order block when a directional candle is followed by consecutive rising or falling bars that meet a configurable minimum percentage price change threshold. When detected, the script draws high, low, and optional midpoint channel lines with descriptive labels extending forward. Users can configure the lookback period, percent move threshold, maximum displayed channels, line extensions, and light or dark color schemes.

Details

Published by

jawauntb on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance

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
Color SchemestringLIGHTcolors
Relevant Periods to identify OBint7periods
Min. Percent move for valid OBfloat0.0threshold
Number of Bullish Channels to showint10bull_channels
Number of Bearish Channels to showint10bear_channels
Show Labelsbooltrueshow_labels
Show Mid Labelsbooltrueshow_mid_labels
Extend Linesbooltrueextend_lines
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

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
303 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

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