// @version=4
// authors Vincent Bollaert //
study(title="MA EMA MTF ribbon", shorttitle="MA EMA MTF ribbon", overlay = true)
ticker_id = tickerid(syminfo.prefix, syminfo.ticker)
// ----- colors ----- //
color_transparent = color.new(color.white, 100)
color_green = color.new(color.green, 65)
color_green_transparent = color.new(color.green, 90)
color_red = color.new(color.red, 65)
color_red_transparent = color.new(color.red, 90)
// ----- EMA ----- //
input_ema_1 = input(title="Ribbon 1 low (EMA)", type=input.integer, defval=72)
input_ema_1_tf = input(title="timeframe", type=input.resolution, defval="240")
input_ema_2 = input(title="Ribbon 1 high (EMA)", type=input.integer, defval=89)
input_ema_2_tf = input(title="timeframe", type=input.resolution, defval="240")
input_ema_3 = input(title="Ribbon 2 low (EMA)", type=input.integer, defval=72)
input_ema_3_tf = input(title="timeframe", type=input.resolution, defval="5")
input_ema_4 = input(title="Ribbon 2 high (EMA)", type=input.integer, defval=89)
input_ema_4_tf = input(title="timeframe", type=input.resolution, defval="5")
input_ema_5 = input(title="200(EMA)", type=input.integer, defval=200)
input_ema_5_tf = input(title="timeframe", type=input.resolution, defval="240")
input_ema_6 = input(title="200(EMA)", type=input.integer, defval=600)
input_ema_6_tf = input(title="timeframe", type=input.resolution, defval="240")
ema_1 = ema(close, input_ema_1)
ema_2 = ema(close, input_ema_2)
ema_3 = ema(close, input_ema_3)
ema_4 = ema(close, input_ema_4)
ema_5 = ema(close, input_ema_5)
ema_6 = ema(close, input_ema_6)
output_ema_1 = security(ticker_id, input_ema_1_tf, ema_1)
output_ema_2 = security(ticker_id, input_ema_2_tf, ema_2)
output_ema_3 = security(ticker_id, input_ema_3_tf, ema_3)
output_ema_4 = security(ticker_id, input_ema_4_tf, ema_4)
output_ema_5 = security(ticker_id, input_ema_5_tf, ema_5)
output_ema_6 = security(ticker_id, input_ema_6_tf, ema_6)
ema_plot_1 = plot(output_ema_1, color=color_transparent, title="Ribbon 1 low (EMA)")
ema_plot_2 = plot(output_ema_2, color=color_transparent, title="Ribbon 1 high (EMA)")
ema_plot_3 = plot(output_ema_3, color=color_transparent, title="Ribbon 2 low (EMA)")
ema_plot_4 = plot(output_ema_4, color=color_transparent, title="Ribbon 2 high (EMA)")
ema_plot_5 = plot(output_ema_5, color=color_transparent, title="200(EMA)")
ema_plot_6 = plot(output_ema_6, color=color_transparent, title="200(EMA)")
fill(ema_plot_1, ema_plot_2, color = output_ema_1 > output_ema_2 ? color_green : color_red)
fill(ema_plot_3, ema_plot_4, color = output_ema_3 > output_ema_4 ? color_green: color_red)