MACD Indicator for 5 Min Scalp
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pluckyCraft54926

//@version=5
indicator("MACD Indicator")
fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
src = input(title="Source", defval=close)
signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)
sma_source = input.string(title="Oscillator MA Type",  defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])
// Plot colors
col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")
col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")
col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
hist_1m = request.security(syminfo.tickerid,"1",hist [barstate.isrealtime ? 1 : 0])
hline(0, "Zero Line", color=color.new(#787B86, 50))


////////////////////////////////////////////////////////
srcBB = hist_1m
lengthBBLong = input.int(94,title = "Length BB Long", minval=1)
lengthBBShort = input.int(8,title = "Length BB Short", minval=1)
multBB = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basisBBLong = ta.sma(srcBB, lengthBBLong)
basisBBShort = ta.sma(srcBB, lengthBBShort)
devBBLong = multBB * ta.stdev(srcBB, lengthBBLong)
devBBShort = multBB * ta.stdev(srcBB, lengthBBShort)
upperBB = basisBBShort + devBBShort
lowerBB = basisBBLong - devBBLong
offsetBB = input.int(0, "Offset", minval = -500, maxval = 500)
p1 = plot(upperBB, "Upper", color=#2962FF, offset = offsetBB)
p2 = plot(lowerBB, "Lower", color=#2962FF, offset = offsetBB)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
//////////////////////////////////////////////////////////777

plotting = hist_1m <= lowerBB or hist_1m >= upperBB
normalcolor = hist_1m>=0 ? (hist_1m[1] < hist_1m ? col_grow_above : col_fall_above) : (hist_1m[1] < hist_1m ? col_grow_below : col_fall_below)
plot(hist_1m, title="Histogram", style=plot.style_columns, color=plotting ? normalcolor : color.gray)

alertcondition(plotting,"Bigger then avarage Tick")
