The code you have now would make more sense as you are setting BarBrush/BarBrushes[0] under specific conditions rather than at random places in OnBarUpdate.
When OnBarUpdate is processing an update of a bar, line 60 checks if the current close is greater than 1.05 times the previous close.
In the else statement, BarBrush/BarBrushes[0] is set to null to reset it to the original bar color.
If you want the conditions to be processed on the developing bar, consider setting the script to use Calculate.OnPriceChange.
Comment