Linear Regression Candles With OB LEO
Linear Regression Candles With OB LEO
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © wugamlo
//@version=4
study("Linear Regression Candles with OB LEO", format=format.price, precision=4,
overlay = true)
// Color Scheme
bullcolor = colors == "DARK"? color.white : color.green
bearcolor = colors == "DARK"? color.blue : color.red
int upcandles = 0
for i = 1 to periods
upcandles := upcandles + (close[i] > open[i]? 1 : 0) //
Determine color of subsequent candles (must all be green to identify a valid
Bearish OB)
int downcandles = 0
for i = 1 to periods
downcandles := downcandles + (close[i] < open[i]? 1 : 0) //
Determine color of subsequent candles (must all be red to identify a valid Bearish
OB)
// Plotting
line.delete(linebull2)
linebull2 := line.new(x1 = bar_index, y1 = OB_bull_high, x2 = bar_index - 1, y2
= OB_bull_high, extend = extend.left, color = bullcolor, style = line.style_dashed,
width = 1)
line.delete(linebull3)
linebull3 := line.new(x1 = bar_index, y1 = OB_bull_low, x2 = bar_index - 1, y2
= OB_bull_low, extend = extend.left, color = bullcolor, style = line.style_dashed,
width = 1)
line.delete(linebear2)
linebear2 := line.new(x1 = bar_index, y1 = OB_bear_high, x2 = bar_index - 1, y2
= OB_bear_high, extend = extend.left, color = bearcolor, style =
line.style_dashed, width = 1)
line.delete(linebear3)
linebear3 := line.new(x1 = bar_index, y1 = OB_bear_low, x2 = bar_index - 1, y2
= OB_bear_low, extend = extend.left, color = bearcolor, style = line.style_dashed,
width = 1)
if OB_bull_avg > 0
latest_bull_avg := OB_bull_avg
if OB_bull_low > 0
latest_bull_low := OB_bull_low
if OB_bear_high > 0
latest_bear_high := OB_bear_high
if OB_bear_avg > 0
latest_bear_avg := OB_bear_avg
if OB_bear_low > 0
latest_bear_low := OB_bear_low
// Plot invisible characters to be able to show the values in the Data Window
plotchar(latest_bull_high, char = ' ', location = location.abovebar, color =
#777777, transp = 100, size = size.tiny, title = "Latest Bull High")
plotchar(latest_bull_avg, char = ' ', location = location.abovebar, color =
#777777, transp = 100, size = size.tiny, title = "Latest Bull Avg")
plotchar(latest_bull_low, char = ' ', location = location.abovebar, color =
#777777, transp = 100, size = size.tiny, title = "Latest Bull Low")
plotchar(latest_bear_high, char = ' ', location = location.abovebar, color =
#777777, transp = 100, size = size.tiny, title = "Latest Bear High")
plotchar(latest_bear_avg, char = ' ', location = location.abovebar, color =
#777777, transp = 100, size = size.tiny, title = "Latest Bear Avg")
plotchar(latest_bear_low, char = ' ', location = location.abovebar, color =
#777777, transp = 100, size = size.tiny, title = "Latest Bear Low")
panel_text = '\n' + title + '\n' + row0 + '\n' + row1 + '\n' + row2 + '\n' + row3 +
'\n' + row4 + '\n\n' + row5 + '\n' + row6 + '\n' + row7 + '\n'
if info_pan
draw_InfoPanel(panel_text, info_panel_x, info_panel_y, size.normal)
if showdocu
l_docu := label.new(x = time + chper * 35, y = close, text = "DOCU OB",
color=color.gray, textcolor=color.white, style=label.style_label_center, xloc =
xloc.bar_time, yloc=yloc.price, size=size.tiny, textalign = text.align_left,
tooltip = vartooltip)
plot(signal, color=color.blue)