DMA Thrust Count Notification
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pleasedHare87433

//@version=4
study("Thrust Count Notification", precision=0)
var thrustCount = 0

a = input(true, title="Enable 1st MA")
len = input(3, minval=1, title="Length")
src = input(close, title="Source")
off = input(3, title="offset")
out = sma(src, len)
outoff = offset(out, 3)

if low > outoff or high < outoff
    thrustCount := thrustCount + 1

if cross(low, outoff) or cross(high, outoff)
    thrustCount := 0
    
_color = close > outoff ? color.green : color.red

threshould = input(title="Thrust Threshold", type=input.integer, defval=8, minval=1, step = 1)

shouldAlert = thrustCount > 8
alertcondition(shouldAlert, title="High Thrust", message="Thrust > 8 for {{ticker}}")

plot(thrustCount, title="Thrust Count", style=plot.style_histogram, color=_color, linewidth=3)



