The LBR_PaintBars study transforms regular color scheme of the price plot according to its relation to Volatility Lines thus signifying trend direction. The bars whose close price is above Volatility Lines are displayed as bullish (green) and the bars that close below Volatility Lines are painted as bearish (red); otherwise, the regular color coding is kept.

Volatility Lines are calculated using the following algorithm. The first line represents the sum of the factorized moving average of the Average True Range (ATR) and the lowest low on the specified period. The second line is plotted as the difference of the highest igh on the same period and the factorized average of the ATR.


Input Parameters

Parameter Description
hl length The period on which the highest high and the lowest low prices are found.
atr length The number of bars used in the calculation of the ATR and its moving average.
factor The factor by which the average of the ATR is multiplied.
paint bars Defines whether or not to paint bars according to the algorithm (green for bullish trend, red for bearish trend).
average type

The type of moving average to be used in calculations: simple, exponential, weighted, Wilder's, or Hull.


Plot Description
UpperVolatility Boolean plot marking Close price values that are above Volatility Lines.
LowerVolatility Boolean plot marking Close price values that are below Volatility Lines.


*For illustrative purposes only. Not a recommendation of a specific security or investment strategy.