Guest User

LBR Paintbars for TradingView [LazyBear]

a guest
Feb 25th, 2015
2,481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. //
  2. // @author LazyBear
  3. // List of all my indicators:
  4. // https://docs.google.com/document/d/15AGCufJZ8CIUvwFJ9W-IKns88gkWOKBCvByMEvm5MLo/edit?usp=sharing
  5. //
  6. study("LBR PaintBars [LazyBear]", overlay=true, shorttitle="LBRBARS_LB")
  7. lbperiod = input (16, title="HL Length")
  8. atrperiod = input(9, title="ATR Length")
  9. mult = input (2.5, minval=0, title="ATR Multiplier")
  10. bcf = input(true, title="Color LBR Bars?")
  11. mnlb=input(false, title="Color non LBR Bars?" )
  12. svb=input(false, title="Show Volatility Bands?")
  13. mkb=input(true, title="Mark LBR bars above/below KC?")
  14. lengthKC = input(20, minval=1, title="KC Length")
  15. multKC = input(1.5, title="KC Multiplier")
  16. useTR = input(true, title="Use TR for KC")
  17. skb=input(false, title="Show KC?")
  18. calc_kc(source, useTR, length, mult) =>
  19. ma = ema(source, length)
  20. range = useTR ? tr : high - low
  21. rangema = ema(range, length)
  22. upper = ma + rangema * mult
  23. lower = ma - rangema * mult
  24. [upper, ma, lower]
  25.  
  26. [u,b,l] = calc_kc(close, useTR, lengthKC, multKC)
  27. uk=plot(skb?u:na, color=gray, linewidth=1, title="KC Upper"), lk=plot(skb?l:na, color=gray, linewidth=1, title="KC Lower")
  28. fill(uk,lk,gray), plot(skb?b:na, style=circles, color=orange, linewidth=2, title="KC Basis")
  29. kct=mkb ? (close >= u or close <= l) : false
  30. aatr = mult * sma(atr(atrperiod), atrperiod)
  31. b1 = lowest(low, lbperiod) + aatr
  32. b2 = highest(high, lbperiod) - aatr
  33. uvf = (close > b1 and close > b2)
  34. lvf = (close < b1 and close < b2 )
  35. uv = plot(svb?b2:na, style=line, linewidth=3, color=red, title="UpperBand")
  36. lv = plot(svb?b1:na, style=line, linewidth=3, color=green, title="LowBand")
  37. bc = (bcf ? kct?fuchsia:(uvf ? lime : lvf ? maroon : mnlb?blue:na) : (not (uvf or lvf) and mnlb ? blue : na ) )
  38. barcolor(bc)
Advertisement
Add Comment
Please, Sign In to add comment