This has been copied from another thread, but here’s how to set custom bar colours as per the following rules:
Green bars for when the body of candlestick is more than 50% of the range and a higher close:
// get the range of the bar r1 = HIGH()-LOW(); // get the absolute value of the body b1 = ABS(close()-OPEN()); // is body > 50% of range? v1 = b1 / r1 > 0.5; //true and close is up v1 and CLOSE() IsUp
Red bars when body > 50% of range and the close is lower:
// get the range of the bar r1 = HIGH()-LOW(); // get the absolute value of the body b1 = ABS(close()-OPEN()); // is body > 50% of range? v1 = b1 / r1 > 0.5; //true and close is down v1 and CLOSE() IsDown
When neither of the above is true set the All Scripts colour option to blue:
Another example:
https://forum.optuma.com/topic/jim-bergs-blue-bar-volatility-signal/