31 lines
1.2 KiB
Plaintext
31 lines
1.2 KiB
Plaintext
//@version=5
|
|
indicator(title="SunnyBands Indicator", shorttitle="SunnyBands", overlay=true)
|
|
|
|
// Inputs
|
|
length = input.int(50, title="DMA Length")
|
|
atr_multiplier = input.float(1.5, title="ATR Multiplier")
|
|
smooth_factor = input.int(2, title="Smoothing Factor")
|
|
|
|
// Double EMA (DMA)
|
|
ema1 = ta.ema(close, length)
|
|
dma = ta.ema(ema1, smooth_factor)
|
|
|
|
// ATR Calculation
|
|
atr = ta.atr(length)
|
|
|
|
// Upper & Lower Bands
|
|
upper_band = dma + (atr * atr_multiplier)
|
|
lower_band = dma - (atr * atr_multiplier)
|
|
|
|
// Bullish & Bearish Signals
|
|
bullish_signal = ta.crossover(close, lower_band) // Close crosses above lower band
|
|
bearish_signal = ta.crossunder(close, upper_band) // Close crosses below upper band
|
|
|
|
// Plotting Bands
|
|
plot(dma, title="DMA", color=color.blue, linewidth=2)
|
|
plot(upper_band, title="Upper Band", color=color.red, linewidth=2)
|
|
plot(lower_band, title="Lower Band", color=color.green, linewidth=2)
|
|
|
|
// Entry & Exit Markers
|
|
plotshape(bullish_signal, location=location.belowbar, style=shape.triangleup, color=color.green, size=size.small, title="Bullish Signal")
|
|
plotshape(bearish_signal, location=location.abovebar, style=shape.triangledown, color=color.red, size=size.small, title="Bearish Signal") |