MarginRockets 5 Mins Ultimate Scalp v1
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ahmedashraf20999
//@version=4

study("5 Mins Complex alert", overlay =true)
len = input(14)
th = input(20)
TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0
SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
ADX = sma(DX, len)
//plot(DIPlus, color=color.green, title="DI+")
//plot(DIMinus, color=color.red, title="DI-")
//plot(ADX, color=color.navy, title="ADX")
//hline(th, color=color.black)
//--------------
// Define Variables
ema200 = ema(close, 200)
vwma20 = vwma (close,20)
volumeaverage = sma(volume, 30)
volumetrue = volume > volumeaverage
Long_signal = close > ema200 and volumetrue and ADX >20 and DIPlus > DIMinus and close > open
Short_signal = close < ema200 and volumetrue and ADX >20 and DIMinus > DIPlus and open > close
// Plot Decision
plotshape (Long_signal,style=shape.arrowup,color=color.green)
plotshape (Short_signal,style=shape.arrowdown,color = color.red)
plot(series=ema200, color=color.blue, linewidth=2)
plot(series=vwma20, color=color.yellow, linewidth=1)
//Alert Setup
alertcondition(Long_signal,title = "Long Signal", message = "Long Ya Basha")
alertcondition(Short_signal,title = "Short Signal",message = "Short Ya Basha")