ErroMsg in OrderSend

[Deleted]  

Hi guys,

i tried to open a trade via EA as a marketorder. It should be a BUYING Order with a Stop Loss of 25 Pips and a Target of 25 Pips.

      ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-0.0025,Bid+0.0025);
      if(ticket<0)
      {
      Alert(Symbol(),": OrderSend failed with error #",GetLastError());
      return(false);
      }

I wrote this code but it does not open a trade! Instead it sends me the error code #130. But why? I can't find the error.


I read on this site but couldn't find a solution.

https://book.mql4.com/trading/ordersend

 
FamWue:

Hi guys,

i tried to open a trade via EA as a marketorder. It should be a BUYING Order with a Stop Loss of 25 Pips and a Target of 25 Pips.

I wrote this code but it does not open a trade! Instead it sends me the error code #130. But why? I can't find the error.

Is your Broker an ECN type Broker ?  (<- - - -  click the link)
 
FamWue:
i tried to open a trade via EA as a marketorder. It should be a BUYING Order with a Stop Loss of 25 Pips and a Target of 25 Pips.
 ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-0.0025,Bid+0.0025);
I wrote this code but it does not open a trade! Instead it sends me the error code #130. But why? I can't find the error.
  1. 0.0025 is NOT 25 pips on all pairs (E.g. USDJPY)
  2. Adjust for 4/5 digit brokers. (TP, SL, AND slippage).
  3. Adjust for ECN
//++++ These are adjusted for 5 digit brokers.
int      pips2points;                  // slippage  3 pips  3=points 30=points
double   pips2dbl;                     // Stoploss 15 pips  0.0015   0.00150
int      Digits.pips;                  // DoubleToStr(dbl/pips2dbl, Digits.pips)
int      init(){
    if(Digits % 2 == 1){   // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345
            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());
   //}