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=4
study("OrderBlox Acc/Dist", "OrderBlox", true, max_bars_back=300, max_labels_count=300)

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

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

////////////////////////////
//        OrderBlock      //
////////////////////////////

//Inputs

adlength   = input(defval=12,  title="Accumulation/Distribution Length", type=input.integer, minval=1, maxval=100, group="OrderBlock Settings")
wickperc   = input(defval=100, title="Wick Percentage",                  type=input.integer, minval=1, maxval=100, group="OrderBlock Settings", tooltip="Candle Wick Percentage to be taken into account (100 = Disabled).")
adboxcount = input(defval=20,  title="Maximum Box Displayed",            type=input.integer, minval=1, maxval=200, group="OrderBlock Settings")

//Constant Price Variables

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

//Box Variables

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

//Box Color Variables

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

//Accumulation/Distribution Variables

int bearcandle = 0
int bullcandle = 0

//Bearish/Bullish Candle Detection

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

//Accumulation/Distribution Calculation

abs   = abs(open[offset] - close[offset]) / abs(high[offset] - low[offset]) <= wickperc / 100
ad    = sum((close == high and close == low or high == low ? 0 : ((close - open) / (high - low)) * volume), 12)
norm  = 100 * ad / 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
            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
            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.