Bull & Bear Volume-by-Price levels

Category: Indicators By: Nicolas Created: July 5, 2018, 1:48 PM
July 5, 2018, 1:48 PM
Indicators
58 Comments

This “Volume-by-Price” indicator shows the amount of volume for a particular price range selected with the “lookback” setting, which is based on closing prices. The bars are horizontal and shown on the left side of the chart to correspond with these price ranges. The bars are separated into 2 colors to clearly identify the bull and bear Volumes in each price range. By combining volume and closing prices, this indicator can be used to identify high-volume price ranges to mark support or resistance.

The code shows 12 Volume-by-Price bars by default, but users can increase or decrease this number to suit their preferences with the “NbrBars” setting. Be aware that due to some ProBuilder limitations, this setting, as well as the lookback one, cannot be extended very much.

For a better visualization of which side has higher volumes on each price range, I added a small square of the corresponding color.

The ScaleFactor setting is used to adapt the length of the bars, depending of your choice to have small or big bars plotted over the price chart.

//PRC_Bull&Bear Volume on Price | indicator
//05.07.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

defparam drawonlastbaronly=true
defparam calculateonlastbars=1000

// --- settings 
ScaleFactor = 5
NbrBars=12
lookback=200
// --- end of settings 

hh=highest[lookback](high)
ll=lowest[lookback](low)
div = (hh-ll)/NbrBars
i=0
volsum=summation[lookback](volume)
startbar = barindex[lookback]
while i<NbrBars do
 lrange=ll+div*i
 hrange=lrange+div
 volbull=0
 volbear=0
 for j = 1 to lookback do
  if close[j]>=lrange and close[j]<=hrange then
   if close[j]>open[j] then
    volbull=volbull+volume[j]
   else
    volbear=volbear+volume[j]
   endif
  endif
 next
 bullbar = round((volbull*lookback)/volsum)*scalefactor
 bearbar = round((volbear*lookback)/volsum)*scalefactor

 drawrectangle(startbar,lrange,startbar+bullbar,hrange) coloured(46,139,87)
 drawrectangle(startbar,lrange,startbar+bearbar,hrange) coloured(255,0,0)

 if bullbar>bearbar then 
  drawtext("■",startbar+bullbar,(lrange+hrange)/2,Dialog,Bold,22) coloured(46,139,87)
 else
  drawtext("■",startbar+bearbar,(lrange+hrange)/2,Dialog,Bold,22) coloured(255,0,0)
 endif
 i=i+1
wend
drawvline(barindex[lookback])

return 

 

Download
Filename: PRC_BullBear-Volume-on-Price.itf
Downloads: 1215
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...