MultiTimeFlame MultipleMovingAverage - MTF MultiMA

2nd Version of MTF MA series.
You can use MTF 5MAs and you can also select [SMA, EMA , HMA , RMA, WMA and VWAM] in this script.
Please give me advice, if you can write more concise script!

前作に加え、移動平均線の選択肢を[SMA, EMA , HMA , RMA, WMA , VWAM]に増やしました。

Sep 20
Release Notes: コメントを一部修正
Remove from Favorite Scripts Add to Favorite Scripts
this case doesn't work...

study("MultiTimeFlame MultipleMovingAverage", shorttitle="MTF MultiMA", overlay=true)

// Select Moving Average
MAswitch = input(title="MAstyle", type=string, defval="EMA", options=)

ma(_src, _length) =>
if MAswitch == "EMA"
_return = ema(_src, _length)
if MAswitch == "SMA"
_return = sma(_src, _length)
if MAswitch == "HMA"
_return = wma((2 * wma(_src, _length / 2)) - wma(_src, _length), round(sqrt(_length)))
if MAswitch == "RMA"
_return = rma(_src, _length)
if MAswitch == "WMA"
_return = wma(_src, _length)
if MAswitch == "VWMA"
_return = vwma(_src, _length)
// _return = ema(_src, _length)

//Set MA Values
maA = input(title='MA1 期間', type=integer, minval=1, step=1, defval=50)
maB = input(title='MA2 期間', type=integer, minval=1, step=1, defval=80)
maC = input(title='MA3 期間', type=integer, minval=1, step=1, defval=100)
maD = input(title='MA4 期間', type=integer, minval=1, step=1, defval=200)
maE = input(title='MA5 期間', type=integer, minval=1, step=1, defval=400)

//Set MA resolutions
resA = input(title='MA1 時間足', type=resolution, defval="3")
resB = input(title='MA2 時間足', type=resolution, defval="5")
resC = input(title='MA3 時間足', type=resolution, defval="15")
resD = input(title='MA4 時間足', type=resolution, defval="30")
resE = input(title='MA5 時間足', type=resolution, defval="60")

//Set MA switches
maAswitch = input(title="MA1 On/Off", type=bool, defval=true)
maBswitch = input(title="MA2 On/Off", type=bool, defval=true)
maCswitch = input(title="MA3 On/Off", type=bool, defval=true)
maDswitch = input(title="MA4 On/Off", type=bool, defval=true)
maEswitch = input(title="MA5 On/Off", type=bool, defval=true)

//Get MA data
dataA = security(tickerid, resA, ma(close, maA))
dataB = security(tickerid, resB, ma(close, maB))
dataC = security(tickerid, resC, ma(close, maC))
dataD = security(tickerid, resD, ma(close, maD))
dataE = security(tickerid, resE, ma(close, maE))

plot(maAswitch ? dataA : na, color=black, linewidth=2)
plot(maBswitch ? dataB : na, color=black, linewidth=2)
plot(maCswitch ? dataC : na, color=black, linewidth=2)
plot(maDswitch ? dataD : na, color=black, linewidth=2)
plot(maEswitch ? dataE : na, color=black, linewidth=2)
Home Stock Screener Forex Screener Crypto Screener Economic Calendar Shows How It Works Chart Features Pricing House Rules Pine Wizards Moderators Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Help Center Refer a friend Feature Request Blog & News Twitter
Profile Profile Settings Account and Billing Refer a friend My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out