LBR Paintbars [LazyBear]

Added coloring of LB bars above/below Keltner Channel (as suggested by user @20813 below in the comments).

Updated code:

See comments section below for a sample chart. Copy the code from the pastebin above and update your local copy (TV doesn't allow me to update an already published code -- yet!).

Added features:
- Switch ON/OFF KC
- Mark LB bars above/below KC


The LBR PaintBars indicator changes the colour of the price bars based on the trend direction (derived from price & volatility bands). This is mostly used as a confirmation indicator.

For the Pine coders: I suggest trying stdev() in lieu of atr()...some wild combinations can be derived from this simple idea :)

Indicator supports the following options:
- Switching on/off volatility bands
- Switching on/off LBR colors (lime/maroon).
- Color non-LBR bars (blue).

Thanks @mseaworthy for pinging me with this idea.

Complete list of my indicators:
Remove from Favorite Scripts Add to Favorite Scripts
// @author LazyBear 
// List of all my indicators: 
study("LBR PaintBars [LazyBear]", overlay=true, shorttitle="LBRBARS_LB")
lbperiod = input (16, title="HL Length")
atrperiod = input(9, title="ATR Length")
mult = input (2.5, minval=0, title="ATR Multiplier")
bcf = input(true, title="Color LBR Bars?")
mnlb=input(false, title="Color non LBR Bars?" )
svb=input(false, title="Show Volatility Bands?")
aatr = mult * sma(atr(atrperiod), atrperiod) 
b1 = lowest(low, lbperiod) + aatr 
b2 = highest(high, lbperiod) - aatr 
uvf =  (close > b1 and close > b2)
lvf = (close < b1 and close < b2 )
uv = plot(svb?b2:na, style=line, linewidth=3, color=red, title="UpperBand")
lv = plot(svb?b1:na, style=line, linewidth=3, color=green, title="LowBand")
bc = (bcf ? uvf ? lime : lvf ? maroon : mnlb?blue:na : (not (uvf or lvf) and mnlb ? blue : na ) )
Do you have an oscillator plot to go with this color series?
"Wild Ideas"??? Questions: 1. Please explain advantage of using st dev vs. ATR in terms of effective use of the indicator. 2. If there is an advantage, could you please show what the code would be & where it would go (I'd be glad to do it myself). Also, is there more info about this indicator? Thanks
LazyBear rmwaddelljr
To rephrase your question 1, you are wondering about "advantage of Bollinger bands over Keltner channel" (BB uses stdev, KC uses atr). There is no clear favorite for me (though I end up using BB most of the time, just because I am relatively more familiar with it than KC).

Here are some links I found on Google for LBRPaintbar:

rmwaddelljr LazyBear
Thanks. I did google before I posted this morning. Interesting. So how would you modify the code to reflect either (ATR or StDev)?
LazyBear rmwaddelljr
It uses ATR now. To use stdev(), change atr(atrperiod) to stdev(close, atrperiod). Also change atrperiod to 20 (to reflect standard BB).

If you use the new code (, you might want to change the calc_kc to calc_stdev and use that for all calculations/renderings.
rmwaddelljr LazyBear
How do I fix "line 8:8 no viable alternative at input"
LazyBear rmwaddelljr
Can you show me that code?
rmwaddelljr LazyBear
atrperiod, close = input (9, title= "ATR Length")
LazyBear rmwaddelljr
"atrperiod, close=" has syntax error.

It shd read "atrperiod=input(...)"
rmwaddelljr LazyBear
Sorry, now confused. You said earlier today to use: It uses ATR now. To use stdev(), change atr(atrperiod) to stdev(close, atrperiod). Also change atrperiod to 20 (to reflect standard BB)... Where am I going wrong?
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
HE עברית
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out