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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
//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 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials