The Peak Activity Levels indicator displays support and resistance levels from prices accompanied by significant volume . The indicator includes a histogram returning the frequency of closing prices falling between two parallel levels, each bin shows the number of bullish candles within the levels.
1. Settings
- Length: Lookback for the detection of volume peaks.
- Number Of Levels: Determines the number of levels to display.
- Levels Color Mode: Determines how the levels should be colored. "Relative" will color the levels based on their location relative to the current price. "Random" will apply a random color to each level. "Fixed" will use a single color for each level.
- Levels Style: Style of the displayed levels. Styles include solid, dashed, and dotted.
1.1 Histogram
- Show Histogram: Determines whether to display the histogram or not.
- Histogram Window: Lookback period of the histogram calculation.
2. Usage
The indicator can be used to display ready-to-use support and resistance . These are constructed from peaks in volume . When a peak occurs, we take the price where this peak occurred and use it as the value for our level.
If one of the levels was previously tested, we can hypothesize that the level might be used as support/resistance in the future. Additional analysis using volume can be done in order to confirm a potential bounce.
The histogram can return various information to the user. It can show if the price stayed within two levels for a long time and if the price within two levels was mostly made of bullish or bearish candles.
The histogram can return various information to the user. It can show if the price stayed within two levels for a long time and if the price within two levels was mostly made of bullish or bearish candles.
In the chart above, we can see that over the most recent 200 bars (determined by Histogram Window) 68 closing prices fall between levels A and B, with 27 bars being bullish .
Additionally, the width of a bin and its length can sometimes give information about the volatility of a specific price variation. If a bin is very wide but short (a low number of closing prices fallen within the levels) then we can conclude a most of the movement was done on a short amount of time.
Additionally, the width of a bin and its length can sometimes give information about the volatility of a specific price variation. If a bin is very wide but short (a low number of closing prices fallen within the levels) then we can conclude a most of the movement was done on a short amount of time.
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // © LuxAlgo //@version=4 study("Peak Activity Levels [LUX]",overlay=true,max_bars_back=2000,max_lines_count=500,max_boxes_count=500) length = input(20,minval=1) show = input(5,'Number Of Levels',minval=1) line_col = input('Fixed','Levels Color Mode',options=['Relative','Random','Fixed']) lvl_style = input('──','Levels Style',options=['──','- - -','· · ·']) relative_col_up = input(#2157f3,'',inline='lvlcol') relative_col_dn = input(#ff5d00,'',inline='lvlcol') fixed_col = input(#2157f3,'Fixed Color',inline='lvlcol') show_hist = input(true,'Show Histogram',group='Histogram') distwin = input(200,'Histogram Window',maxval=500,group='Histogram') upcol = input(color.new(#2157f3,50),'Bins Colors',group='Histogram',inline='col') dncol = input(color.new(#ff5d00,50),'',group='Histogram',inline='col') //---- var color css = na var lines = array.new_line(0) var upbox = array.new_box(0) var dnbox = array.new_box(0) var randcol = array.new_color(0) if barstate.isfirst for i = 0 to show-1 array.push(lines,line.new(na,na,na,na)) array.push(upbox,box.new(na,na,na,na)) array.push(dnbox,box.new(na,na,na,na)) if line_col == 'Random' array.push(randcol,color.rgb(random(0,255),random(0,255),random(0,255))) //---- os = 0. n = bar_index src = close var y = array.new_float(0) //---- ph = pivothigh(volume,length,length) if ph array.unshift(y,src[length]) //---- a = 0. b = 0. if barstate.islast slice = array.slice(y,0,show+1) array.sort(slice) for i = 0 to show-1 lvl = array.get(y,i) if line_col =='Relative' css := src > lvl ? relative_col_up : relative_col_dn else if line_col =='Random' css := array.get(randcol,i) else css := fixed_col l = array.get(lines,i) line.set_xy1(l,n,lvl) line.set_xy2(l,n-1,lvl) line.set_extend(l,extend.right) line.set_color(l,css) if lvl_style == '- - -' line.set_style(l,line.style_dashed) else if lvl_style == '· · ·' line.set_style(l,line.style_dotted) up = 1 dn = 1 if show != 1 and i != 0 and show_hist for j = 0 to distwin-1 a := array.get(slice,i) b := array.get(slice,i-1) up := max(a,b) > src[j] and min(a,b) < src[j] and src[j] > open[j] ? up+1 : up dn := max(a,b) > src[j] and min(a,b) < src[j] and src[j] < open[j] ? dn+1 : dn sum = up + dn box_a = array.get(dnbox,i) box_b = array.get(upbox,i) box.set_rightbottom(box_a,n+sum,min(a,b)) box.set_lefttop(box_a,n+up,max(a,b)) box.set_border_color(box_a,na) box.set_bgcolor(box_a,dncol) box.set_rightbottom(box_b,n+1,max(a,b)) box.set_lefttop(box_b,n+up,min(a,b)) box.set_border_color(box_b,na) box.set_bgcolor(box_b,upcol)