//@version=5 indicator("Sunny Bands", shorttitle="SunnyB", overlay=true, format=format.price, precision=2) // Input parameters matching Python class length = input.int(50, "DMA Length", minval=1) atr_multiplier = input.float(1.5, "ATR Multiplier", minval=0.1, step=0.1) smooth_factor = input.int(2, "Smoothing Factor", minval=1) // Double EMA (DMA) calculation matching Python implementation ema1 = ta.ema(close, length) dma = ta.ema(ema1, smooth_factor) // ATR calculation equivalent to Python version atr = ta.atr(length) // Calculate bands upper_band = dma + (atr * atr_multiplier) lower_band = dma - (atr * atr_multiplier) // Signal detection using crossovers bullish = ta.crossover(close, lower_band) bearish = ta.crossunder(close, upper_band) // Store plot references for fill dma_plot = plot(dma, "DMA", color=color.new(#009688, 0), linewidth=2) upper_plot = plot(upper_band, "Upper Band", color=color.new(#FF5252, 0), linewidth=2) lower_plot = plot(lower_band, "Lower Band", color=color.new(#4CAF50, 0), linewidth=2) // Correct fill using plot references fill(upper_plot, lower_plot, color.new(#673AB7, 90), "Band Area") // Signal markers plotshape( series=bullish, title="Bullish Signal", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small ) plotshape( series=bearish, title="Bearish Signal", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small ) // Alerts equivalent to get_signals() method alertcondition(bullish, title="Bullish Signal Detected", message="Sunny Bands: Bullish crossover of lower band") alertcondition(bearish, title="Bearish Signal Detected", message="Sunny Bands: Bearish crossunder of upper band")