Help to error code 130 (Invalid stop)

 

Could someone please help fix the error code 130?

When I run a tester it was okay to get a result without any error code.

But I had an error code 130 when it attached to chart and runing real time with the demo account.

While running the tester, for example, the journal showed "opened price : 1.30003, stoploss : 1.29503, takeprofit : 1.30503 - OK".

However during real time runing with M5 EUR:USD chart of demo account I had an "Error opening SELL order : 130" and then could not open any order.

extern double TakeProfit = 500;
extern double StopLoss = 500;
extern double Lots = 0.1;
extern double TrailingStop =500;

   total=OrdersTotal();
   if(total<1) 

   ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,30,Ask-StopLoss*Point,Ask+TakeProfit*Point,"macd",16384,0,Green);
   ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Bid+StopLoss*Point,Bid-TakeProfit*Point,"macd",16384,0,Red);


// had an "Error opening SELL order : 130" then change stop loss to 0 but still same error again

   ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,30,0,Ask+TakeProfit*Point,"ma",16384,0,Green);
   ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,30,0,Bid-TakeProfit*Point,"ma",16384,0,Red);

Thanks for your help!!!

Regards,

Seung

 

What did the documentation tell you when you looked up Error 130 ?

What did search tell you when you searched for Error 130 ?

Try this: ECN

 
RaptorUK:

What did the documentation tell you when you looked up Error 130 ?

What did search tell you when you searched for Error 130 ?

Try this: ECN


Thanks Raptor for your reply... Curretly i do not know GFT is ECN or not and I will confirm.

 
You'd solve your problem faster by testing OrderSend with with SL and Tp at 0.
 
seungbaek:
Thanks Raptor for your reply... Curretly i do not know GFT is ECN or not and I will confirm.
Why do you care? Just code it for ECN and it works on any broker.
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.015      0.0150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
     if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
    /* On ECN brokers you must open first and THEN set stops
    int ticket = OrderSend(..., 0,0,...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)
       Alert("OrderModify failed: ", GetLastError());
     */
Reason: