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.

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.
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('Acc/Dist OrderBlock Retracement', 'Acc/Dist OrderBlock Retracement', true, max_bars_back=1000, max_lines_count=500, max_labels_count=500) //═════ CUSTOMIZATION ═════ highcolor = input.color(defval=color.red, title='Distribution Zones', inline='customcolor', group='Chart Customization') lowcolor = input.color(defval=color.blue, title='Accumulation Zones', inline='customcolor', group='Chart Customization') //════════ INPUTS ═════════ adlength = input.int(defval=12, title='Accumulation/Distribution Length', minval=1, maxval=100, group='OrderBlock Settings') linecount = input.int(defval=10, title='Maximum Lines', minval=1, maxval=200, group='Retracement Settings') layout = input.string(defval='Wick', title='Lines Type', options=['Wick', 'Zone', 'Average'], group='Retracement Settings', inline='lines') linestyle = input.string(defval='Solid', title='Lines Style', options=['Solid', 'Dotted', 'Dashed'], group='Retracement Settings', inline='lines') linessize = input.int(defval=2, title='Lines Size', minval=1, maxval=3, group='Retracement Settings', inline='lines') extend = input.bool(defval=false, title='Extend Lines?', group='Retracement Settings', inline='lines') //Price Variables Declaration close_ = close low_ = low high_ = high open_ = open bar_index_ = bar_index //Color Call Function fzonecolor(obcolor, _call) => c1 = color.r(obcolor) c2 = color.g(obcolor) c3 = color.b(obcolor) color.rgb(c1, c2, c3, _call) //Round Function round_f(x) => math.round(x / syminfo.mintick) * syminfo.mintick //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 - close) / math.abs(high - low) / 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 //Retracement Lines Variables Declaration var int numberofline = linecount var float upperphzone = na var float upperplzone = na var float lowerphzone = na var float lowerplzone = na var line[] upperphzonearr = array.new_line(0, na) var line[] upperplzonearr = array.new_line(0, na) var line[] lowerphzonearr = array.new_line(0, na) var line[] lowerplzonearr = array.new_line(0, na) var line upperphzoneline = na var line upperplzoneline = na var line lowerphzoneline = na var line lowerplzoneline = na var bool[] upperzonetestedarr = array.new_bool(0, false) var bool[] lowerzonetestedarr = array.new_bool(0, false) var bool upperzonetested = false var bool lowerzonetested = false var bool nobool = true var bool showprice = true var color upperzonecolor = highcolor var color lowerzonecolor = lowcolor var label[] labelpharr = array.new_label(0, na) var label[] labelplarr = array.new_label(0, na) var label labelph = na var label labelpl = na //Lines Styles String f_linestyle(_style) => _style == 'Solid' ? line.style_solid : _style == 'Dotted' ? line.style_dotted : line.style_dashed //Top Retracement Lines Calculation if adbear upperphzone := high_ upperplzone := close_ < open_ ? close_ : open_ upperplzoneline := layout == 'Zone' ? line.new(bar_index_, upperplzone, bar_index, upperplzone, width=linessize) : na upperphzoneline := layout != 'Average' ? line.new(bar_index_, upperphzone, bar_index, upperphzone, width=linessize) : line.new(bar_index_, (upperphzone + upperplzone) / 2, bar_index, (upperphzone + upperplzone) / 2, width=linessize) labelph := showprice ? label.new(bar_index_, layout != 'Average' ? upperphzone : (upperphzone + upperplzone) / 2, text=str.tostring(bar_index - bar_index_), textcolor=upperzonecolor, style=label.style_none) : na if array.size(upperphzonearr) > numberofline line.delete(array.shift(upperphzonearr)) line.delete(array.shift(upperplzonearr)) array.shift(upperzonetestedarr) label.delete(array.shift(labelpharr)) array.push(upperphzonearr, upperphzoneline) array.push(upperplzonearr, upperplzoneline) array.push(upperzonetestedarr, extend ? true : false) array.push(labelpharr, labelph) if array.size(upperplzonearr) > 0 for i = 0 to array.size(upperplzonearr) - 1 by 1 line tempupperline = array.get(upperphzonearr, i) line templowerline = array.get(upperplzonearr, i) label linepricelabel = array.get(labelpharr, i) bool tested = array.get(upperzonetestedarr, i) line.set_style(tempupperline, f_linestyle(linestyle)) line.set_style(templowerline, f_linestyle(linestyle)) line.set_color(tempupperline, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), fzonecolor(upperzonecolor, 00))) line.set_color(templowerline, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), fzonecolor(upperzonecolor, 00))) label.set_textcolor(linepricelabel, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), upperzonecolor)) label.set_text(linepricelabel, str.tostring(round_f(line.get_y1(tempupperline)))) label.set_text(linepricelabel, ' Top Retracement - ' + str.tostring(round_f(line.get_y1(tempupperline)))) label.set_x(linepricelabel, bar_index) crossed = high > line.get_y1(tempupperline) if crossed and not tested array.set(upperzonetestedarr, i, true) label.delete(linepricelabel) alert('Top Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested : not tested line.set_x2(tempupperline, bar_index) array.set(upperphzonearr, i, tempupperline) line.set_x2(templowerline, bar_index) array.set(upperplzonearr, i, templowerline) //Bottom Retracement Lines Calculation if adbull lowerplzone := low_ lowerphzone := close_ < open_ ? open_ : close_ lowerphzoneline := layout == 'Zone' ? line.new(bar_index_, lowerphzone, bar_index, lowerphzone, width=linessize) : na lowerplzoneline := layout != 'Average' ? line.new(bar_index_, lowerplzone, bar_index, lowerplzone, width=linessize) : line.new(bar_index_, (lowerphzone + lowerplzone) / 2, bar_index, (lowerphzone + lowerplzone) / 2, width=linessize) labelpl := showprice ? label.new(bar_index_, layout != 'Average' ? lowerplzone : (lowerphzone + lowerplzone) / 2, text=str.tostring(bar_index - bar_index_), textcolor=lowerzonecolor, style=label.style_none) : na if array.size(lowerphzonearr) > numberofline line.delete(array.shift(lowerphzonearr)) line.delete(array.shift(lowerplzonearr)) array.shift(lowerzonetestedarr) label.delete(array.shift(labelplarr)) array.push(lowerphzonearr, lowerphzoneline) array.push(lowerplzonearr, lowerplzoneline) array.push(lowerzonetestedarr, extend ? true : false) array.push(labelplarr, labelpl) if array.size(lowerplzonearr) > 0 for i = 0 to array.size(lowerplzonearr) - 1 by 1 line tempupperline = array.get(lowerphzonearr, i) line templowerline = array.get(lowerplzonearr, i) label linepricelabel = array.get(labelplarr, i) bool tested = array.get(lowerzonetestedarr, i) line.set_style(tempupperline, f_linestyle(linestyle)) line.set_style(templowerline, f_linestyle(linestyle)) line.set_color(tempupperline, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), fzonecolor(lowerzonecolor, 00))) line.set_color(templowerline, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), fzonecolor(lowerzonecolor, 00))) label.set_textcolor(linepricelabel, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), lowerzonecolor)) label.set_text(linepricelabel, str.tostring(round_f(line.get_y1(templowerline)))) label.set_text(linepricelabel, ' Bottom Retracement - ' + str.tostring(round_f(line.get_y1(templowerline)))) label.set_x(linepricelabel, bar_index) crossed = low < line.get_y1(templowerline) if crossed and not tested array.set(lowerzonetestedarr, i, true) label.delete(linepricelabel) alert('Bottom Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested : not tested line.set_x2(tempupperline, bar_index) array.set(lowerphzonearr, i, tempupperline) line.set_x2(templowerline, bar_index) array.set(lowerplzonearr, i, templowerline)
The content covered on this website is NOT investment advice and I am not a financial advisor.