OPEN-SOURCE SCRIPT

MTF Order Block Finder

Updated
An Order Block is a special type of pivot point that satisfies the following requirement:
A Bull/Bear candle followed by X consecutive candles in the opposite direction.

Order Blocks are interesting areas that are frequently revisited and can be treated as Support/Resistance levels.
Often, you can see explosive price rejection of these areas via long wicks, high volume, and rapid price change.

Features
Choose from two themes:
- LIGHT: a classic Red and Green representing Bearish and Bullish OBs, respectively
- DARK: a clean Blue and White scheme

Choose from two drawing styles:
- LINE: three lines representing the High, Low, and Mid price levels of the OB candle
- BOX: a bounded area similar to the "rectangle" tool

Chose a custom timeframe:
- From 1 Minute (useful for Seconds interval) up to 1 Month
Note, this setting is experimental and choosing a timeframe that is extraordinarily large may not function properly.

Filter order blocks with two settings:
- Number of consecutive bars
- Minimum % change of the potential OB bar (default 0.25%)

Keep your charts clean and show only relevant OBs
- Maximum number of Bullish zones to show
- Maximum number of Bearish zones to show

FAQ
Q:How do I trade with this indicator?
A:Personally, I use a fast entry indicator to confirm Long/Short position when price is rejected. I set my SL and TP based on the current Zone and the next one, if available.

Q:Does this repaint?
A:Yes and this is okay! The "Bear" and "Bull" signals are not meant for taking positions, only showing which candle reveals the Order Block. The Zone is much more useful to us and can result in several successful trades in the near future when treated as a support/resistance area.

QWhat's the winrate?
A:Hard to say - this isn't a standalone strategy and I haven't been able to properly backtest it quite yet.
Release Notes
Added "Fuzzy Logic" support!
This is useful if you have a near-perfect Order Block setup, but one candle in the following sequence is a Doji
New setting: Fuzzy Logicf Percent Move
If the % change from Open to Close is less than your Fuzzy Logic percentage, we consider it to be part of the 5 bar sequence.

Release Notes
Bug Fixes
  • Fuzzy Logic bug fix
  • Fuzzy Logic default value is now more strict (reduced to 0.01% from 0.05%)
  • Zones previously drawn with additional 1-candle delay; Zones now created on close of last candle in OB sequence
  • Second candle is now considered the "Order Block" and the zone High/Low is based on this candle
Release Notes
Dojis and Bug Fixes
  • Added support for filtering OBs by Doji! Choose to ignore an OB when it starts with a Doji
  • Fixed issues with MTF drawings when using LINE mode
  • Cleaned up code
Release Notes
Settings changes, feature requests, and upgrades!

1. New default values for settings
  • Min. Percent move for valid OB (0.25% -> 0.3%)
  • Max Bullish Zones to show (2 -> 4)
  • Max Bearish Zones to show (2 -> 4)
  • Ignore Dojis at Start (disabled -> enabled)


2. Requested Features
  • Bullish/Bearish Zone color - set your own color and transparency instead of choosing from presets
  • Line Widths for High/Low and Avg- set your own line width when using the LINE drawing style


3. Upgrades
Order Block Draw Distance
Often times when using an Intraday chart and drawing MTF Order Blocks, you'll see
your candles shrink and compress - this can be very annoying, especially on TradingView mobile.

TradingView automatically resizes the chart to keep ALL drawings within view and unfortunately,
there are no chart settings to "ignore" drawings that aren't relevant to current price.

Now you can set a Draw Distance by percent (%) change to hide Order Blocks that are
very distant from current price.

Using this setting has several benefits:
  • MTF Order Block zones plot much faster (less objects for TV to draw)
  • Allows you to have many Order Blocks (more than the default of 4) and only show most relevant
  • Overall less frustration! No need to take your chart off "Auto" and resize it manually

Release Notes
Small Upgrade!
  • Improved logic for filtering away Dojis
  • Improved clarity on several Settings tooltips
  • Reduced "Max Bars Back" requirement (Load OBs from older bars)
Release Notes
MASSIVE UPDATE
Introducing several new settings, improved MTF plotting, and basic Alerts (see below for details)

3 new experimental settings!
  • Order Block Candle Shift
  • Order Block Source Selector
  • Order Block Context Search Length

All of which contribute to the creation of Order Block zones in different ways.

Order Block Candle Shift
Shift the source candle that is used for drawing Zones.
Example: For a Bullish OB, a shift of zero selects the first candle of the pattern - the Bearish candle before a sequence of Bulls.
Default = 1 (selecting the second candle)

Order Block Source Selector
Choose the price values to extract from the Order Block candle. These prices are used to draw the Zone. Default is "High/Low"
  • High/Low Mode = High and Low of OB Candle.
  • OHLC Mode = From the High/Low of the OB Candle to the Open/Close, whichever is in the direction of the OB.
  • Context Mode = Context sensitive algorithm. Picks the largest wick near the OB candle, given a search length.


Order Block Context Search Length
When using Context Mode, you can tweak the search length for the Source Selector. Example: the Default of 2 will start with the first candle of the pattern and then check the following two candles

Improved MTF Plotting
We no longer use the plotshape function, which has many MTF irregularities and drawbacks.
All plotting is done through the Line, Box, and Label functions of Pinescript.
A major benefit is highlighting the entire series of candles on a lower TF in which a higher TF Order Block comes from.
Check out the updated chart image above to get an idea of what this means (Using 4h resolution on a 15m chart)

Alerts
New simple alerts for when a new Bullish and Bearish Order Block is created.
I have plans to create 3 new alert functions for the next update:
  • A candle opening outside of and then closing within an Order Block
  • A candle opening inside of and then closing outside an Order Block
  • A candle wicking into an Order Block


Thank all so much for the wonderful support and feedback!
Release Notes
FINAL UPDATE
This script is Open Source and completely free and will remain public indefinitely!

We'll be releasing a Private Script with extremely useful Alert Conditions in ~1 Week!
Consider following my Profile to see updates regarding trial periods and subscriptions.


New Alert Condition
  • Alert on creation of any new OB (previously must select Bearish or Bullish)


New Option for "Order Block Zone Drawing Style"
  • BOTH - will overlay LINE and BOX style zone, allowing you to see the average-line in addition to a clear colored area.


Bug Fixes
  • On intraday charts with a higher TF resolution for OBs - zones had a chance of being drawn multiple times, resulting in duplicates. Fixed!
  • Setting a Line width to 0 did not hide the line. Fixed!
Release Notes
Removed settings that violate House Rules
Release Notes
Bugs Squashed
Fixed issues with "input sanitization" and "Array out of Range" errors
Release Notes
Small Update

More accurate descriptions of settings, renamed settings, moved settings into more logical groupings.
Release Notes
Small Patch

Fixed an issue specifically with loading 10m Order Blocks on the 1m chart!
Release Notes
Small Bug Fixes

- Added a filter that ignores Zero-Tick candles, which are characterized by no change in price and have no high or low wicks.
- Setting 1st or 2nd+ candle filters to Zero now require a candle with at least 1 tick of price change.
- Improved speed on Order Block Identification by ~100%
Release Notes
Medium Priority Bug Fixes

There was a difficult-to-detect issue when using the "2nd Candle Filter" that would prevent full functionality!
This fix addresses the issue. Now, you can properly choose choose to ignore Dojis or small candles within an Order Block Sequence.

Example Usage:
You notice a strong historical bullish reversal that is not being recognized as a "Bull OB".
Upon closer inspection, you see that the pattern contains 3 Bullish candles, 1 Bearish doji, and a Bullish candle at the end.
The Bear doji is causing the pattern to not be recognized as a "Bull OB".
You notice the Bear doji is only a 0.02% move, from Open to Close and decide that the pattern is still valid, even with this doji.

You can change the "2nd Candle Filter" value to 0.025, which will accept the Bear doji since it's move % is smaller than your filter.
Now the Bullish reversal is properly recognized and drawn on chart. You may also notice other "imperfect" reversals are now detected!
dasancopensourceorderblockspivotPivot PointssupportSupport and Resistancezonetrading

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Algo Trading Simplified 👉 PaxProfits.com
Discover the easy way to manage Forex trading accounts. Trusted by traders globally.

Forex Trading Coaching 👉 primetimefox.com
Learn consistent currency pair trading from a professional.
Also on:

Disclaimer