Volume-by-price levels indicator (with Highest/Lowest and Breakdown options)

Category: Indicators By: Meta Signals Pro Created: February 1, 2019, 9:49 AM
February 1, 2019, 9:49 AM
Indicators
0 Comments

Hi Coders,

Based on the first indicator made by Nicolas (https://www.prorealcode.com/prorealtime-indicators/bull-bear-volume-by-price-levels/),

I needed further options to have this indicator automatically adjusted on the Highest-high or the Lowest-Low of a determined lookback period. I wanted also to have a feel of the global volume per price without the breakdown of bull and bear volume depending on the closure direction.

Here it is!

Hope it will enlighten some price moves 😉

Please feel free to give to this code some enhancements or if you want to develop strategies based on it please share them.

Chris

//VolumeByPrice HighLowBreakdown (mods by Kris75)
//PRC_Bull&Bear Volume on Price | indicator
//05.07.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

defparam drawonlastbaronly=true

// --- settings
StartHighest = 1 //(0=false, 1=true)
StartLowest = 0 //(0=false, 1=true)
breakdown = 0 //(0=false, 1=true)
ScaleFactor = 5
NbrBars=25
lookback=50
// --- end of settings

if StartHighest then

 StartVol=highest[lookback](high)
 for j=lookback downto 0 do
  if high[j]=StartVol then
   LastStartBar = j
   drawtext("#LastStartBar#",barindex[j],high[j])
   break
  endif
 next

elsif not StartHighest and StartLowest then
 StartVol=lowest[lookback](high)
 for j=lookback downto 0 do
  if high[j]=StartVol then
   LastStartBar = j
   drawtext("#LastStartBar#",barindex[j],high[j])
   break
  endif
 next

else// (not StartHighest and not StartLowest) or (StartHighest and StartLowest) then
 LastStartBar = lookback
endif

LastStartBar = max(1,LastStartBar)

hh=highest[LastStartBar](high)
ll=lowest[LastStartBar](low)
div = (hh-ll)/NbrBars
i=0
volsum=summation[LastStartBar](volume)
startbar = barindex[LastStartBar]
while i<NbrBars do
 lrange=ll+div*i
 hrange=lrange+div
 volbull=0
 volbear=0
 for j = 1 to LastStartBar 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*LastStartBar)/volsum)*scalefactor
 bearbar = round((volbear*LastStartBar)/volsum)*scalefactor
 volbar = round(((volbear+volbull)*LastStartBar)/volsum)*scalefactor

 //MaxWidth=barindex-startbar
 //volbar = round((volbear+volbull)/volsum)*MaxWidth*scalefactor

 if breakdown then

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

  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
  drawvline(barindex[lookback])
 elsif not breakdown then

  drawrectangle(startbar,lrange,startbar+volbar,hrange) coloured(46,139,87,255)


 endif
 drawvline(barindex[LastStartBar])
 i=i+1
wend


return

Download
Filename: VolumeByPrice-HighLowBreakdown.itf
Downloads: 478
Meta Signals Pro Veteran
MetaSignalsPro is operated by a small, expert team with a strong background in manual / systematic trading and risk management. Our work is driven by 15 years of practical experience in live market conditions. Please visit: https://market.prorealcode.com/store/meta-signals-pro/ To get the BEST strategies of ProrealCode Please visit: https://www.prorealcode.com/topic/the-best-trading-strategies-of-prc-for-prorealtime-backtests-update-rankings/
Author’s Profile

Comments

Logo Logo
Loading...