OrderBlox Acc/Dist

Indicator working on the same logic as my other indicator “Institutional OrderBlock Pressure”. But this one uses Accumulation/Distribution as a reference to find OrderBlock instead of Price Action. This has a much cleaner interface and represents the Zones of OrderBlock by “Box”. It can work in addition to “Institutional OrderBlock pressure”.

Orderblox Acc/Dist in action on Dow Jones Index.

Screenshot taken from the Settings menu of Orderblox Acc/Dist.

Here is the complete list of features present in this indicator :

  • Full Indicator Customization
  • OB Detection by Accumulation/Distribution
  • Acc/Dist Length

This indicator do not have any Alerts.

Rate this Indicator?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this Indicator.

5
(1)

Or copy / paste the source code into your pine editor :

/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RickSimpson

//@version=5
indicator('OrderBlox Acc/Dist', 'OrderBlox', true, max_bars_back=300, max_labels_count=300)

//═════ CUSTOMIZATION ═════

highcolor = input.color(defval=color.red,   title='High Zones Color', inline='customcolor', group='Chart Customization')
lowcolor  = input.color(defval=color.green, title='Low Zones Color',  inline='customcolor', group='Chart Customization')
adtransp  = input.int(defval=65,            title='Box Transparency', minval=1, maxval=100, group='Chart Customization')

////////////////////////////
//        OrderBlox       //
////////////////////////////

//Inputs

adlength   = input.int(defval=12, title='Accumulation/Distribution Length', minval=1, maxval=100, group='OrderBlock Settings')
adboxcount = input.int(defval=20, title='Maximum Box Displayed',            minval=1, maxval=200, group='OrderBlock Settings')

//Price Variables Declaration

int offset = 0 + 1
close_     = close[offset]
low_       = low[offset]
high_      = high[offset]
open_      = open[offset]
bar_index_ = bar_index[offset]

//Box Variables Declaration

var box[] bearboxarray = array.new_box()
var box[] bullboxarray = array.new_box()

//Box Color Variables Declaration

var color adbearboxcolor       = color.new(highcolor, adtransp)
var color adbullboxcolor       = color.new(lowcolor,  adtransp)
var color adbearborderboxcolor = color.new(highcolor,        0)
var color adbullborderboxcolor = color.new(lowcolor,         0)

//Accumulation/Distribution Variables Declaration

int bearcandle = 0
int bullcandle = 0

//Bearish/Bullish Candle Calculation

for i = 1 to 0 by 1
    bearcandle := bearcandle + (close[i] > open[i] ? 1 : 0)
    bearcandle
for i = 1 to 0 by 1
    bullcandle := bullcandle + (close[i] < open[i] ? 1 : 0)
    bullcandle

//Accumulation/Distribution Calculation

abs   = math.abs(open[offset] - close[offset]) / math.abs(high[offset] - low[offset]) / 100
ad    = math.sum(close == high and close == low or high == low ? 0 : (close - open) / (high - low) * volume, adlength)
norm  = 100 * ad / math.sum(volume, adlength)
adcum = norm > 0 and norm > norm[1]

//Conditions

adbear = adcum and (bearcandle == (0)) and abs
adbull = adcum and (bullcandle == (0)) and abs

//Bearish AD Box Calculation

f_choppedoffbear(bearboxarray) =>
    if array.size(bearboxarray) > 0
        for i            = array.size(bearboxarray) - 1 to 0 by 1
            cutbox       = array.get(bearboxarray, i)
            boxlowzone   = box.get_bottom(cutbox)
            boxhighzone  = box.get_top(cutbox)
            boxrightzone = box.get_right(cutbox)
            if na or bar_index - 1 == boxrightzone and not(high > boxlowzone and low < boxlowzone or high > boxhighzone and low < boxhighzone)
                box.set_right(array.get(bearboxarray, i), bar_index)

//Bearish AD Box Plotting

if adbear
    boxhighzone = high_
    boxlowzone  = close_ < open_ ? close_ : open_
    bearbox     = box.new(bar_index_, boxhighzone, bar_index, boxlowzone, border_color=adbearborderboxcolor, border_style=line.style_dashed, bgcolor=adbearboxcolor)
    if array.size(bearboxarray) > adboxcount
        box.delete(array.shift(bearboxarray))
    array.push(bearboxarray, bearbox)

f_choppedoffbear(bearboxarray)

//Bullish AD Box Calculation

f_choppedoffbull(bullboxarray) =>
    if array.size(bullboxarray) > 0
        for i            = array.size(bullboxarray) - 1 to 0 by 1
            cutbox       = array.get(bullboxarray, i)
            boxlowzone   = box.get_bottom(cutbox)
            boxhighzone  = box.get_top(cutbox)
            boxrightzone = box.get_right(cutbox)
            if na or bar_index - 1 == boxrightzone and not(high > boxlowzone and low < boxlowzone or high > boxhighzone and low < boxhighzone)
                box.set_right(array.get(bullboxarray, i), bar_index)

//Bullish AD Box Plotting

if adbull
    boxlowzone  = low_
    boxhighzone = close_ < open_ ? open_ : close_
    bullbox     = box.new(bar_index_, boxhighzone, bar_index, boxlowzone, border_color=adbullborderboxcolor, border_style=line.style_dashed, bgcolor=adbullboxcolor)
    if array.size(bullboxarray) > adboxcount
        box.delete(array.shift(bullboxarray))
    array.push(bullboxarray, bullbox)

f_choppedoffbull(bullboxarray)

The content covered on this website is NOT investment advice and I am not a financial advisor.