MA package
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OldGrumpyCat
//@version=4
study(title="均線群【老猫】", overlay=true)

longsmoothing = input(title="均線類型", defval="EMA", options=["RMA", "SMA", "EMA", "WMA", "ALMA"])
ma_fun(s, length) =>
    if s == "RMA"
        rma(close, length)
    else
        if s == "SMA"
            sma(close, length)
        else
            if s == "EMA"
                ema(close, length)
            else
                if s == "ALMA"
                    alma(close, length, 0.85, 6)
                else
                    wma(close, length)
                    
ma1 = input(5, minval = 1, title = "MA1")
ma2 = input(8, minval = 1, title = "MA2")
ma3 = input(13, minval = 1, title = "MA3")
ma4 = input(50, minval = 1, title = "MA4")
ma5 = input(55, minval = 1, title = "MA5")
ma6 = input(60, minval = 1, title = "MA6")
ma7 = input(100, minval = 1, title = "MA7")
ma8 = input(150, minval = 1, title = "MA8")
ma9 = input(200, minval = 1, title = "MA9")

e1 = ma_fun(longsmoothing, ma1)
e2 = ma_fun(longsmoothing, ma2)
e3 = ma_fun(longsmoothing, ma3)
e4 = ma_fun(longsmoothing, ma4)
e5 = ma_fun(longsmoothing, ma5)
e6 = ma_fun(longsmoothing, ma6)
e7 = ma_fun(longsmoothing, ma7)
e8 = ma_fun(longsmoothing, ma8)
e9 = ma_fun(longsmoothing, ma9)

plot(e1, color = #2196f3)
plot(e2, color = #00bcd4)
plot(e3, color = #4caf50)
plot(e4, color = #ffeb3b)
plot(e5, color = #ff9800)
plot(e6, color = #f44336)
plot(e7, color = #444444)
plot(e8, color = #040404)
plot(e9, color = #000000)