Candle and BG Trend Identifier
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © creksar_stock
//@version=5
indicator("Candle and BG microtrend identifier", "Microtrend Based Candles", true)

hifunc = high > high[1]
lofunc = low < low[1]
bgcolor(hifunc ? color.new(color.green, 85) : lofunc ? color.new(color.red, 85) : na)

hiline = lofunc ? line.new(bar_index + 25, high, bar_index, high, color = color.new(color.red, 100), width = 2) : na
loline = hifunc ? line.new(bar_index + 25, low, bar_index, low, color = color.new(color.green,100), width = 2) : na

color colorandom = hifunc ? color.new(color.green,30) : lofunc ? color.new(color.red,30) : color.silver
plotcandle(open, high, low, close, "Bearish Candle", color = colorandom, wickcolor = colorandom, editable = false)

//color.new(color.green,30)
//color.new(color.red,30)

