Advertisement
lazybeartv

Belkhayate Timing v2 [LazyBear]

Apr 11th, 2015
3,755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. //
  2. // @author LazyBear
  3. //
  4. // List of my public indicators: http://bit.ly/1LQaPK8
  5. // List of my app-store indicators: http://blog.tradingview.com/?p=970
  6. //
  7. // v02 - support for osc candles (@TheMightyChicken)
  8. //
  9. study("Belkhayate Timing [LazyBear]", shorttitle="BT_LB", overlay=false)
  10. showHLC=input(true, title="Smooth Osc?"), showHisto=input(false, title="Show Histogram?")
  11. showCandles=input(false), colorCandles=input(true, title="Color Osc Candles (valid only if ShowCandles is enabled)")
  12. Range1=input(4), Range2=input(8), ebc=input(false, title="Enable Barcolors")
  13. middle = (((high + low) / 2) + ((high[1] + low[1]) / 2) + ((high[2] + low[2]) / 2) + ((high[3] + low[3]) / 2) + ((high[4] + low[4]) / 2)) / 5
  14. scale = (((high - low) + (high[1] - low[1]) + (high[2] - low[2]) + (high[3] - low[3]) + (high[4] - low[4])) / 5) * 0.2
  15. h = (high - middle) / scale
  16. l = (low - middle) / scale
  17. o = (open - middle) / scale
  18. c = (close - middle) / scale
  19. ht=showHLC?avg(h, l, c):c
  20. l1=plot(Range1, title="SellLine1", color=gray)
  21. l2=plot(Range2, title="SellLine2", color=gray)
  22. l3=plot(-Range1, title="BuyLine1", color=gray)
  23. l4=plot(-Range2, title="BuyLine2", color=gray)
  24. fill(l1,l2,red, title="OBZone"), fill(l3,l4, lime, title="OSZone")
  25. bc=ht>0?(ht>=Range2?blue:(ht>=Range1?green:lime)):(ht<=-Range2?blue:(ht<=-Range1?maroon:red))
  26. barcolor(ebc?bc:na)
  27. plot(0, title="ZeroLine", color=gray)
  28. plot(showHisto and (not showCandles)?ht:na, style=histogram, title="BTOscHistogram", linewidth=1, color=ht>0?green:red)
  29. plot(showCandles?na:ht, style=line, title="BTOsc", linewidth=3, color=gray)
  30. //
  31. // Thanks @TheMightyChicken for the candles code
  32. // Updated to show candle colors, and an option to switch between osc or candles view.
  33. //
  34. bHigh = o > c ? o : c
  35. bLow = o < c ? o : c
  36. b0 = (o > 0 and c > 0) or (o > 0 and c < 0) ? bHigh : (o < 0 and c < 0) or (o < 0 and c > 0) ? bLow : 0
  37. b1 = o < 0 and c > 0 ? bHigh : o > 0 and c < 0 ? bLow : 0
  38. bCover = o > 0 and c > 0 ? bLow : o < 0 and c < 0 ? bHigh : 0
  39. cc=colorCandles?o>c?red:green:silver
  40. w0 = h > 0 ? h : l
  41. w1 = h > 0 and l < 0 ? l : h
  42. wCover = h > 0 and l > 0 ? l : h < 0 and l < 0 ? h : 0
  43. plot(showCandles?b0:na, linewidth=3, color=cc, style=histogram)
  44. plot(showCandles?b1:na, linewidth=3, color=cc, style=histogram)
  45. plot(showCandles?bCover:na, linewidth=3, color=white, style=histogram)
  46. plot(showCandles?w0:na, linewidth=1, color=gray, style=histogram)
  47. plot(showCandles?w1:na, linewidth=1, color=gray, style=histogram)
  48. plot(showCandles?wCover:na, linewidth=1, color=white, style=histogram)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement