Gaussian Average Rate Oscillator
// This source code is subject to the terms of the Mozilla Public License 2.0
// © DraftVenture

//@version=5
indicator("Gaussian Average Rate Oscillator", shorttitle = "GARO", overlay=false)

// Input parameters
source = input(ohlc4, title = "Source")
windowsize = input.int(title="Gaussian Length", defval=26)
maLength = input.int(title = "Baseline Length", defval = 52)
ma_smoothing = input.int(title="Smoothing", defval=9)

// Calculate Averages
alma_value = ta.alma(source, windowsize, 0.85, 6)
ema_value = ta.ema(source, maLength)

// Calculate Smoothing
smoothalma_value = ta.ema(alma_value, ma_smoothing)
sema_value = ta.sma(ema_value, ma_smoothing)

// Calculate ROCs
roc_smoothalma = ta.roc(smoothalma_value, 1)
roc_sema = ta.roc(sema_value, 1)

// Plot ALMA ROC
color_smoothalma = roc_smoothalma > roc_sema ? color.green : roc_smoothalma < roc_sema ? color.red : color.black
color_sema = roc_sema < roc_smoothalma ? color.green : roc_sema > roc_smoothalma ? color.red : color.black

plot(roc_smoothalma, title="Gaussian Plot Area", color=color_smoothalma, linewidth = 2, style=plot.style_histogram)
plot(roc_sema, "Smooth EMA Plot Area", color_sema, linewidth = 2, style = plot.style_histogram)
hline(0, title = "Zero Rate Line", color = color.gray, linestyle = hline.style_solid)

// ______ _________ 
// ___  //_/__  __ \
// __  ,<  __  /_/ /
// _  /| | _  ____/ 
// /_/ |_| /_/      