invalid stops mql5

Amgad Samir Nassief Abdelmalek
152

Hello, I tried to upload an EA  for MT5 but I have errors (invalid stops)

I tried to modify codes

if (slB>Bid && slB<Ask)slB=Bid;
if (tpS>Bid && tpS<Ask)tpS=Bid;
if (slS<Ask && slS>Bid)slS=Ask;
if (tpB<Ask && tpB>Bid)tpB=Ask;

Where: 

tpB is takeProfit foy buy position

tpS is takeProfit for sell position

slB is StopLoss for buy position

and slS is StopLoss for sell position

and all of them are put in position and modifications 

and,

double Ask = NormalizeDouble(SymbolInfoDouble(SymbolArray[j],SYMBOL_ASK),_Digits);
double Bid = NormalizeDouble(SymbolInfoDouble(SymbolArray[j],SYMBOL_BID),_Digits);