This should actually be fairly simple, but I don't see any consideration for 1 standard deviation, or 3 standard deviations, in this code, compared to your first reply. Let me see if I am understanding this correctly:
You want three different colors depending on whether its above 3, 2, or 1 standard deviations. However, you want each of these to also be a different shade depending on whether volume increased or decreased relative to the prior bar. Is this correct?
Just for example, both green bars are above 2 standard deviations in this picture, but the darker green is a decrease:
Here's what I've put together so far
For the Dev increase/decrease I keep those colors the same for simplicity.
I copy and pasted the plot section so I can put all 3 of the different deviation levels in the same indicator
Thats where I reference the different deviation levels ( deviate 1,2 etc. )
I really like how its shaping up !
def Deviation_Length = 60;
def Deviate = 1;
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def abovedev = volumestdev >= Deviate;
def belowdev = volumestdev <= Deviate;
##
plot volumereplace = volume;
volumereplace.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
def increase = volume > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;
volumereplace.DefineColor("Increase", Color.DARK_GREEN);
volumereplace.DefineColor("DevIncrease", Color.GREEN);
volumereplace.DefineColor("Decrease", Color.DARK_RED);
volumereplace.DefineColor("DevDecrease", Color.LIGHT_RED);
volumereplace.AssignValueColor(
if devincrease then volumereplace.Color("DevIncrease")
else
if increase then volumereplace.Color("Increase")
else
if devdecrease then volumereplace.Color("DevDecrease")
else
volumereplace.Color("Decrease"));
AssignPriceColor(if volumestdev >= 0 and volumestdev >1 then Color.orange else Color.CURRENT);
##1
def Deviate1 = 2;
plot volumereplace1 = volume;
volumereplace.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
def increase1 = volume > volume[1];
def devincrease1 = increase and abovedev;
def decrease1 = volume < volume[1];
def devdecrease1= decrease and abovedev;
volumereplace1.DefineColor("Increase", Color.DARK_GREEN);
volumereplace1.DefineColor("DevIncrease", Color.GREEN);
volumereplace1.DefineColor("Decrease", Color.DARK_RED);
volumereplace1.DefineColor("DevDecrease", Color.LIGHT_RED);
volumereplace1.AssignValueColor(
if devincrease1 then volumereplace1.Color("DevIncrease")
else
if increase1 then volumereplace1.Color("Increase")
else
if devdecrease1 then volumereplace1.Color("DevDecrease")
else
volumereplace1.Color("Decrease"));
AssignPriceColor(if volumestdev >= 2 then Color.magenta else Color.CURRENT);
##2
def Deviate2 = 3;
plot volumereplace2 = volume;
volumereplace.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
def increase2 = volume > volume[1];
def devincrease2 = increase and abovedev;
def decrease2 = volume < volume[1];
def devdecrease2= decrease and abovedev;
volumereplace2.DefineColor("Increase", Color.DARK_GREEN);
volumereplace2.DefineColor("DevIncrease", Color.GREEN);
volumereplace2.DefineColor("Decrease", Color.DARK_RED);
volumereplace2.DefineColor("DevDecrease", Color.LIGHT_RED);
volumereplace2.AssignValueColor(
if devincrease2 then volumereplace2.Color("DevIncrease")
else
if increase2 then volumereplace2.Color("Increase")
else
if devdecrease2 then volumereplace2.Color("DevDecrease")
else
volumereplace2.Color("Decrease"));
AssignPriceColor(if volumestdev >= 3 then Color.white else Color.CURRENT);