MA Line Break
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jrob24

//@version=4
study("MA Line Break")
ma = input(title="MA Legnth", type=input.integer, defval=9)
type = input(title="MA Type", type=input.string, options=["SMA","EMA"], defval="SMA")

ma_value = if type == "SMA"
    sma(close,ma)
else if type == "EMA"
    ema(close,ma)

plot(series = (close > ma_value) ? close : na, style=plot.style_linebr, color=color.green, linewidth=2)
plot(series = (close < ma_value) ? close : na, style=plot.style_linebr, color=color.red, linewidth=2, display=display.none) 
