Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // @author LazyBear
- //
- // List of my public indicators: http://bit.ly/1LQaPK8
- // List of my app-store indicators: http://blog.tradingview.com/?p=970
- //
- // v02 - support for osc candles (@TheMightyChicken)
- //
- study("Belkhayate Timing [LazyBear]", shorttitle="BT_LB", overlay=false)
- showHLC=input(true, title="Smooth Osc?"), showHisto=input(false, title="Show Histogram?")
- showCandles=input(false), colorCandles=input(true, title="Color Osc Candles (valid only if ShowCandles is enabled)")
- Range1=input(4), Range2=input(8), ebc=input(false, title="Enable Barcolors")
- 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
- scale = (((high - low) + (high[1] - low[1]) + (high[2] - low[2]) + (high[3] - low[3]) + (high[4] - low[4])) / 5) * 0.2
- h = (high - middle) / scale
- l = (low - middle) / scale
- o = (open - middle) / scale
- c = (close - middle) / scale
- ht=showHLC?avg(h, l, c):c
- l1=plot(Range1, title="SellLine1", color=gray)
- l2=plot(Range2, title="SellLine2", color=gray)
- l3=plot(-Range1, title="BuyLine1", color=gray)
- l4=plot(-Range2, title="BuyLine2", color=gray)
- fill(l1,l2,red, title="OBZone"), fill(l3,l4, lime, title="OSZone")
- bc=ht>0?(ht>=Range2?blue:(ht>=Range1?green:lime)):(ht<=-Range2?blue:(ht<=-Range1?maroon:red))
- barcolor(ebc?bc:na)
- plot(0, title="ZeroLine", color=gray)
- plot(showHisto and (not showCandles)?ht:na, style=histogram, title="BTOscHistogram", linewidth=1, color=ht>0?green:red)
- plot(showCandles?na:ht, style=line, title="BTOsc", linewidth=3, color=gray)
- //
- // Thanks @TheMightyChicken for the candles code
- // Updated to show candle colors, and an option to switch between osc or candles view.
- //
- bHigh = o > c ? o : c
- bLow = o < c ? o : c
- 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
- b1 = o < 0 and c > 0 ? bHigh : o > 0 and c < 0 ? bLow : 0
- bCover = o > 0 and c > 0 ? bLow : o < 0 and c < 0 ? bHigh : 0
- cc=colorCandles?o>c?red:green:silver
- w0 = h > 0 ? h : l
- w1 = h > 0 and l < 0 ? l : h
- wCover = h > 0 and l > 0 ? l : h < 0 and l < 0 ? h : 0
- plot(showCandles?b0:na, linewidth=3, color=cc, style=histogram)
- plot(showCandles?b1:na, linewidth=3, color=cc, style=histogram)
- plot(showCandles?bCover:na, linewidth=3, color=white, style=histogram)
- plot(showCandles?w0:na, linewidth=1, color=gray, style=histogram)
- plot(showCandles?w1:na, linewidth=1, color=gray, style=histogram)
- plot(showCandles?wCover:na, linewidth=1, color=white, style=histogram)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement