a question for ERR_INVALID_STOPS

 

Hi all

I can run my EA in demo account for strategy tester, but it can not work in real live account.

The expert message shows: ERR_INVALID_STOPS (#130). Is anyone can help me to check my EA have anything wrong as below?

if (sma_b_1>sma_b_2&&Low[1]>Low[2]&&Low[2]>Low[3])
{
if (TakeProfit>0) {mtp=Ask+TakeProfit*Point;}else{mtp=0;}
if (StopLoss>0) {msl=Ask-StopLoss*Point;}else{msl=0;}
if (Slip>0) {msp=Slip*Point;}else{msp=0;}
ticket=OrderSend(Symbol(),OP_BUY,LOTS,Ask,msp,msl,mtp,"MACross",MagicN,0,CLR_NONE);
if(ticket<0) {Print("OrderSend failed with error #",GetLastError());} else {RefresThRates();}
raisebuy=false;
return(0);
}

Thx

 

I have heard that some Dealers do not allow you to set SL and TP when opening a trade, you must modify the position after it is opened.

Try doing it manually, or, in your code, Open the trade with no SL or TP and then send OrderModify().

( I may be wrong on this )

Reason: