Based on some rules, I'm creating a score and setting the back colour on the chart. I want to do different shades of green and red, so I'm setting is like this
if (score > 0)
{
//Print("Green brush");
Brush newBrush = myBrushG.Clone();
newBrush.Opacity = .10 * multiplier + .10;
newBrush.Freeze();
BackBrushAll = newBrush;
} else if (score < 0 ){
//Print("Red brush");
Brush newBrush = myBrushR.Clone();
newBrush.Opacity = .10 * multiplier + .10;
newBrush.Freeze();
BackBrushAll = newBrush;
} else {
BackBrushAll = null;
}
The problem is, after a while, during live play, it stays green! I've veridied the code in the score <0 is running with 'print' statements.
In my global variables I have
Brush myBrushG;
Brush myBrushR;
and in stateconfigure I set them like this
myBrushG = Brushes.Green;
myBrushR = Brushes.Red;
myBrushG.Freeze();
myBrushR.Freeze();
I am setting the BrushBackAll in OnBarUpdate, which is set to run on price change, in case that is relevant.
What am I doing wrong? Why does the brush stop working?
Thanks.
Comment