/ This Pine Script™ code is subject to the terms of the Mozilla Public License 2.
0
at https://mozilla.org/MPL/2.0/
// © AlgoTrade_Pro
//@version=6
indicator('Trendilo🤖 [ATP]', overlay = false)
//Inputs
src = close
smooth = input.int(1, title = 'Smoothing', minval = 1)
length = input.int(50, title = 'Lookback', minval = 1)
offset = input.float(0.85, title = 'ALMA Offset', step = 0.01)
sigma = input.int(6, title = 'ALMA Sigma', minval = 0)
bmult = input(1.0, 'Band Multiplier')
cblen = input(false, 'Custom Band Length ? (Else same as Lookback)')
blen = input(20, 'Custom Band Length')
highlight = true
fill = true
//Math
pch = ta.change(src, smooth) / src * 100
avpch = ta.alma(pch, length, offset, sigma)
blength = cblen ? blen : length
rms = bmult * math.sqrt(math.sum(avpch * avpch, blength) / blength)
cdir = avpch > rms ? 1 : avpch < -rms ? -1 : 0
col = cdir == 1 ? color.lime : cdir == -1 ? color.red : color.gray
//Plots for Histogram
fplot = plot(avpch, color = highlight ? col : color.blue, linewidth = 2)
posrms = plot(rms, color = color.new(color.purple, 0))
negrms = plot(-rms, color = color.new(color.purple, 0))
fill(fplot, posrms, color = fill and cdir > 0 ? col : na)
fill(fplot, negrms, color = fill and cdir < 0 ? col : na)
hline(0)
//Signals
Long_Signal = ta.crossover(avpch, rms)
Short_Signal = ta.crossunder(avpch, -rms)
// Plot signals on the chart
plotshape(Long_Signal, title = 'BUY', text = '🟢', style = shape.labelup, location =
location.belowbar, color = color.green, textcolor = color.white, size = size.tiny,
force_overlay = true)
plotshape(Short_Signal, title = 'SELL', text = '🔴', style = shape.labeldown,
location = location.abovebar, color = color.red, textcolor = color.white, size =
size.tiny, force_overlay = true)
// Color the background on signal occurrences
bgcolor(Long_Signal ? #4caf4f33 : na, force_overlay = true, editable = false)
bgcolor(Short_Signal ? #ff525233 : na, force_overlay = true, editable = false)
//End