Brown's Exponential Smoothing Tool (BEST)
// 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("Brown's Exponential Smoothing Tool", "BEST", overlay =  true)

source = input.source(close, "Source")
alpha = input.float(0.01, "Alpha", 0.001, 1, 0.001)
style = input.string("BES", "Style", ["BES","DBES","TBES"])

bes(source, alpha)=>
    var float smoothed = na
    smoothed := na(smoothed) ? source : alpha * source + (1 - alpha) * nz(smoothed[1])

tbes() =>
    e1 = bes(source, alpha)
    e2 = bes(e1,  alpha)
    e3 = bes(e2,  alpha)
    tema = 3 * (e1 - e2) + e3

dbes()=>
    e1 = bes(source, alpha)
    e2 = bes(e1, alpha)
    dema = 2 * e1 - e2

ma()=>
    switch style
        "BES" => bes(source, alpha)
        "DBES" => dbes()
        "TBES" => tbes()

plot(ma(), "MA", color.orange)