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. 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

All options have their original default settings. You need to be able to readjust them depending on the market instrument you want to analyze. You have the possibility to put alerts which will notify you when an indicator gives a new signal. For this, we have united all the alerts in one thanks to the “Any Alert Function Call” option, simply activate or deactivate the options you want to have in your alerts before placing the alert.

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', '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 index  = 1
close_     = close[index]
low_       = low[index]
high_      = high[index]
open_      = open[index]
bar_index_ = bar_index[index]

//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[index] - close[index]) / math.abs(high[index] - low[index]) / 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)
nindex = norm > 0 and norm > norm[1]

//Conditions

adbear = nindex and (bearcandle == (0)) and abs
adbull = nindex 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)

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