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:
Favori Komutlardan Çıkart Favori Komutlara Ekle
// @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?
Cevap Gönder
"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
Cevap Gönder
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:

Cevap Gönder
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)?
Cevap Gönder
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.
Cevap Gönder
rmwaddelljr LazyBear
How do I fix "line 8:8 no viable alternative at input"
Cevap Gönder
LazyBear rmwaddelljr
Can you show me that code?
Cevap Gönder
rmwaddelljr LazyBear
atrperiod, close = input (9, title= "ATR Length")
Cevap Gönder
LazyBear rmwaddelljr
"atrperiod, close=" has syntax error.

It shd read "atrperiod=input(...)"
Cevap Gönder
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?
Cevap Gönder
Ana Sayfa Hisse Senedi Takipçisi Forex Takipçisi Kripto Takipçisi Ekonomik Takvim Gösterimler Nasıl Çalışır Grafik Özellikleri Ücretlendirme Kurallarımız Moderatörler Web Sitesi & Aracı Kurum Çözümleri Görsel Bileşenler(Widget) Grafik Çözümleri Hafif Grafik Kitaplığı Destek Merkezi Bir arkadaşınıza yönlendirin Yeni Özellik Talebi Blog ve Haberler SSS Viki Twitter
Profil Profil Ayarları Hesap ve Ödemeler Bir arkadaşınıza yönlendirin Destek Kayıtlarım Destek Merkezi Yayınlanmış Fikirler Takip Edenler Takip Ediliyor Özel Mesajlar Sohbet Çıkış