TAPLOT SlingShot
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TaPlot

//@version=5

//Code written by @TaPlot
//Written on 11/28/2021


indicator(title="TAPLOT SlingShot", shorttitle="Sling Shot", overlay=true)
C_Paintbar = input.color(title="Bar Color", defval=color.new(color.orange,0))

ShowEMA=input(true,'Show EMA Line?')
Paintbar=input(true,'Paint Bar?')
ShowShape=input(true,'Show SlingShot?')

EMAlen = input.int(4, minval=1, title="EMA-Length")

//MA line calculation
EMALine = ta.ema(high, EMAlen)
plot(ShowEMA?EMALine:na, title="EMA")

slingshot = close > EMALine and close[1] < EMALine[1] and close[2] < EMALine[2] and close[3] < EMALine[3]

alertcondition(slingshot == 1, title='Slingshot', message='Slingshot Triggered!')

plotshape(slingshot and ShowShape?1:na,style=shape.labelup, location=location.belowbar, size=size.tiny)
barcolor(Paintbar and slingshot? C_Paintbar : na)