BarColors can be painted based on the candles close above or below the midline.
The middle region can be shaded only on the side of the closing price.
Finally, the background can also be shaded based on the moving average.
All shading and painting can be turned on or off on the properties window.
4 Paintbar strategies
1. Simple MA above or below
2. Break of band 1. Stays on until break of opposite band
3. Break of band 1. Goes to neutral if on opposite side of MA.
4. Add a control MA (like the 200 hma) and price must also be on the same side as that
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.