Help get this topic noticed by sharing it on Twitter, Facebook, or email. I’m happy

# Volume indicator Edit Subject

Hi,

I would like to create an indicator based on volume.
My idea is the following :

Change the color of the current volume if it is the inverse and two times the size of the previous volume size.

Some one help me ?
3 people have
this question
• I am trying that :

//@version=3
study("VOL x2 RG")
v1 = volume
v2 = volume
c = v2 < v1/2
plot(c, style=columns, color=black)

But create error message :

root_data expression of plot_0 has invalid type: series__bool expected series
How does this make you feel?
I'm
• Pine script won't plot raw booleans, so you will have to convert boolean to numbers. Here is one method of doing so:
```
//@version=3
study("VOL x2 RG")
v1 = volume
v2 = nz(volume) // nz()
c = v2 < v1 / 2
booleanToBinary = c==true ? 1.0 : 0.0
plot(booleanToBinary, style=columns, color=red) ```

When referencing historical values (somevariable[1+]), consider using it in nz(). That way it will avoid NaN and at least provide 0.0.
How does this make you feel?
I'm
• Thanks a lot midtown !

I have adapted your solution at my requirement, works greet :) :

//@version=3
study("VOL x2 RG")

//Volume is two times higher or lower and in opposite direction of the precendent volume/bar
CurrentCloseGreen = open < close
CurrentCloseRed = open > close
BarPrecGreen = open < close
BarPrecRed = open > close
v1 = volume
v2 = nz(volume) // nz()
c1 = CurrentCloseGreen and BarPrecRed and v2 < v1 / 2
c2 = CurrentCloseRed and BarPrecGreen and v2 < v1 / 2
booleanToBinary1 = c1==true ? 1.0 : 0.0
booleanToBinary2 = c2==true ? 1.0 : 0.0
plot(booleanToBinary1, style=columns, color=green)
plot(booleanToBinary2, style=columns, color=red)
How does this make you feel?