Baseline (BL)
// This source code is subject to the terms of the Mozilla Public License 2.0 at
//     https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Baseline", overlay = true)

baseline(float _source = close, simple string _period = "D", string _user = "true", string _custom, bool _manual = false, float _mInput = na) => //can any one explain why I HAD to use a string for my _user "bool" ??
    string self     = syminfo.tickerid
    bool   live     = barstate.isrealtime
    period          = _user == "false" ? _period : _user == "true" ? _custom : "D"
    float  baseline = request.security(self, period, _source[live ? 1 :0])[live ? 0 : 1]
    result          = _manual == false ? baseline : _mInput

period        = input.timeframe("D", "Anchor Period")
custom_toggle = input.bool(false, "Custom Anchor", inline = "toggle")
toggle        = str.tostring(custom_toggle)
custom_input  = input.int(5, "", inline = "toggle")
custom        = str.format("{0,number,integer}", custom_input)
manual_toggle = input.bool(false, "Manual Anchor", inline = "manual")
manual_value  = input.float(0.0, "", inline = "manual")
source        = input.source(close, "Source                 ")

float baseline = baseline(source, period, toggle, custom, manual_toggle, manual_value)

colour_toggle = input.bool(true, "Color Candle", inline = "colour")
colour        = baseline < source ? color.new(#26a69a, 0) : color.new(#ef5350, 0)
colour_enable = colour_toggle == true ? colour : na
colour_tog_bg = input.bool(false, "Color Background", inline = "colour")
colour_bg     = baseline < source ? color.new(#26a69a, 90) : color.new(#ef5350, 90)
colour_fill   = colour_tog_bg == true ? colour_bg : na

barcolor(colour_enable)
price         = plot(source, "source", color.new(color.white, 100), style = plot.style_stepline)
baseline_plot = plot(baseline, "baseline", colour, style = plot.style_stepline)
fill(price, baseline_plot, colour_fill)