Color the Relative Volume Histogram
Forums › ProRealTime English forum › ProBuilder support › Color the Relative Volume Histogram
- This topic has 5 replies, 2 voices, and was last updated 11 months ago by JS.
-
-
12/13/2023 at 8:58 AM #225168
Hi, Some how I cannot manage to color the histogram of the intraday Relative Volume indicator by Nicolas below, into blue for positive and red for negative (attached picture).
Does anybody know which line must be added to the code for this?
Intraday Relative Volume1234567891011121314151617181920212223242526//Relative Volume indicator by NicolasPeriod = 21 //X days averaging periodintraindex = intradaybarindex$ivol[intraindex] = volume$gvol[barindex] = volume$gintraindex[barindex] = intraindexcount = 0sum = 0for i = barindex downto 0 doif $gintraindex[i]=intraindex then //found same intraday barsum=sum+$gvol[i]count=count+1endifif count=period thenbreakendifnextavg = sum/periodrvol = $ivol[intraindex] / avgreturn rvol style(histogram)//$ivol[intraindex], avg coloured(0,0,0)12/13/2023 at 9:42 AM #225178Hi Marcel
The values of the indicator are always greater than zero (no negative values) so you can only set the color of the positive values manually.
Here is the code to color the histogram:
Relative Volume Histogram12345678910111213141516171819202122232425262728293031323334353637//Relative Volume indicator by NicolasPeriod = 21 //X days averaging periodintraindex = intradaybarindex$ivol[intraindex] = volume$gvol[barindex] = volume$gintraindex[barindex] = intraindexcount = 0sum = 0for i = barindex downto 0 doif $gintraindex[i]=intraindex then //found same intraday barsum=sum+$gvol[i]count=count+1endifif count=period thenbreakendifnextavg = sum/periodrvol = $ivol[intraindex] / avgIf rvol>rvol[1] thenR=0G=255B=0ElsIf rvol<rvol[1] thenR=255G=0B=0EndIfreturn rvol style(histogram)Coloured(R,G,B)//$ivol[intraindex], avg coloured(0,0,0)1 user thanked author for this post.
12/13/2023 at 9:59 AM #225182into blue for positive and red for negative 🙂
Relative Volume Histogram12345678910111213141516171819202122232425262728293031323334353637//Relative Volume indicator by NicolasPeriod = 21 //X days averaging periodintraindex = intradaybarindex$ivol[intraindex] = volume$gvol[barindex] = volume$gintraindex[barindex] = intraindexcount = 0sum = 0for i = barindex downto 0 doif $gintraindex[i]=intraindex then //found same intraday barsum=sum+$gvol[i]count=count+1endifif count=period thenbreakendifnextavg = sum/periodrvol = $ivol[intraindex] / avgIf rvol>rvol[1] thenR=0G=0B=255ElsIf rvol<rvol[1] thenR=255G=0B=0EndIfreturn rvol style(histogram)Coloured(R,G,B)//$ivol[intraindex], avg coloured(0,0,0)1 user thanked author for this post.
12/14/2023 at 10:18 AM #225241Thanks JS,
I have adjusted your idea for the code slightly to my original idea, so that the colors now correspond to the colors of the candles. This works a bit easier for me because I have built a screener that selects American stocks with RVol >2.
Relative Volume indicator12345678910111213141516171819202122232425262728293031323334353637383940//Relative Volume indicator by NicolasPeriod = 21 //X days averaging periodintraindex = intradaybarindex$ivol[intraindex] = volume$gvol[barindex] = volume$gintraindex[barindex] = intraindexcount = 0sum = 0for i = barindex downto 0 doif $gintraindex[i]=intraindex then //found same intraday barsum=sum+$gvol[i]count=count+1endifif count=period thenbreakendifnextavg = sum/periodrvol = $ivol[intraindex] / avgIf open>close then//If rvol>rvol[1] thenR=204G=51B=0ElsIf open<close then//ElsIf rvol<rvol[1] thenR=0G=51B=153EndIfreturn rvol style(histogram)Coloured(R,G,B)//$ivol[intraindex], avg coloured(0,0,0)1 user thanked author for this post.
12/15/2023 at 12:44 PM #225276Hi,
Here’s the next hurdle.
It appears that the horizontal line (image) is not held by the indicator as an added indicator or loose line.
This means that every time I open the graph the line has disappeared.
Does anyone know how I can add a solid horizontal line (at 1.5) to the indicator?
Relative Volume12345678910111213141516171819202122232425262728293031323334353637383940//Relative Volume indicator by NicolasPeriod = 21 //X days averaging periodintraindex = intradaybarindex$ivol[intraindex] = volume$gvol[barindex] = volume$gintraindex[barindex] = intraindexcount = 0sum = 0for i = barindex downto 0 doif $gintraindex[i]=intraindex then //found same intraday barsum=sum+$gvol[i]count=count+1endifif count=period thenbreakendifnextavg = sum/periodrvol = $ivol[intraindex] / avgIf open>close then//If rvol>rvol[1] thenR=204G=51B=0ElsIf open<close then//ElsIf rvol<rvol[1] thenR=0G=51B=153EndIfreturn rvol style(histogram)Coloured(R,G,B)//$ivol[intraindex], avg coloured(0,0,0)12/15/2023 at 5:05 PM #225290Hi Marcel,
If you only want a permanent horizontal line in the indicator, you can add the following line in your code (before “Return”):
DrawHLine(1.5) Coloured(“Red”)
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on