//@version=5 indicator("EMA Ribbon [birdsongs]", shorttitle="EMA Ribbon [birdsongs]", overlay=true) // User Inputs for EMA periods and selection minPeriod = input.int(10, title="Minimum EMA Period", minval=1) maxPeriod = input.int(100, title="Maximum EMA Period", minval=1) numEMAs = input.int(10, title="Number of EMAs", minval=1, maxval=10) lineThickness = input.int(2, title="Line Thickness", minval=1, maxval=5) baseOpacity = input.int(25, title="Line Opacity", minval=0, maxval=100, step=5, tooltip="") backgroundOpacity = input.int(50, title="Background Fill Opacity", minval=0, maxval=100, step=5, tooltip="") fillBackground = input.bool(true, title="Fill Background Between EMAs") //Make opacity input intuitive baseOpacity := 100 - baseOpacity if fillBackground backgroundOpacity := 100 - backgroundOpacity else backgroundOpacity := 100 // Calculate the number of EMAs and their period spread periodIncrement = (maxPeriod - minPeriod) / (numEMAs - 1) // Individual EMA calculations ema1 = ta.ema(close, minPeriod) ema2 = ta.ema(close, minPeriod + 1 * periodIncrement) ema3 = ta.ema(close, minPeriod + 2 * periodIncrement) ema4 = ta.ema(close, minPeriod + 3 * periodIncrement) ema5 = ta.ema(close, minPeriod + 4 * periodIncrement) ema6 = ta.ema(close, minPeriod + 5 * periodIncrement) ema7 = ta.ema(close, minPeriod + 6 * periodIncrement) ema8 = ta.ema(close, minPeriod + 7 * periodIncrement) ema9 = ta.ema(close, minPeriod + 8 * periodIncrement) ema10 = ta.ema(close, minPeriod + 9 * periodIncrement) // Plot each EMA p1 = plot(ema1, title="EMA 1", color=color.new(color.rgb(173, 216, 230), baseOpacity), linewidth=lineThickness) p2 = plot(ema2, title="EMA 2", color=color.new(color.rgb(135, 206, 250), baseOpacity), linewidth=lineThickness) p3 = plot(ema3, title="EMA 3", color=color.new(color.rgb(100, 149, 237), baseOpacity), linewidth=lineThickness) p4 = plot(ema4, title="EMA 4", color=color.new(color.rgb(70, 130, 180), baseOpacity), linewidth=lineThickness) p5 = plot(ema5, title="EMA 5", color=color.new(color.rgb(30, 144, 255), baseOpacity), linewidth=lineThickness) p6 = plot(ema6, title="EMA 6", color=color.new(color.rgb(0, 191, 255), baseOpacity), linewidth=lineThickness) p7 = plot(ema7, title="EMA 7", color=color.new(color.rgb(0, 0, 255), baseOpacity), linewidth=lineThickness) p8 = plot(ema8, title="EMA 8", color=color.new(color.rgb(0, 0, 205), baseOpacity), linewidth=lineThickness) p9 = plot(ema9, title="EMA 9", color=color.new(color.rgb(25, 25, 112), baseOpacity), linewidth=lineThickness) p10 = plot(ema10, title="EMA 10", color=color.new(color.rgb(0, 0, 139), baseOpacity), linewidth=lineThickness) // Fill between EMAs with low opacity fill(p1, p2, color=color.new(color.rgb(154, 211, 240), backgroundOpacity)) fill(p2, p3, color=color.new(color.rgb(117, 177, 227), backgroundOpacity)) fill(p3, p4, color=color.new(color.rgb(85, 142, 213), backgroundOpacity)) fill(p4, p5, color=color.new(color.rgb(52, 122, 204), backgroundOpacity)) fill(p5, p6, color=color.new(color.rgb(15, 108, 194), backgroundOpacity)) fill(p6, p7, color=color.new(color.rgb(0, 85, 180), backgroundOpacity)) fill(p7, p8, color=color.new(color.rgb(0, 64, 170), backgroundOpacity)) fill(p8, p9, color=color.new(color.rgb(18, 38, 158), backgroundOpacity)) fill(p9, p10, color=color.new(color.rgb(0, 20, 139), backgroundOpacity))