Advertisements
$ £ ¥
¥ £ $

OrderSend Error 3 (Invalid Trade Parameters)

Sometimes, you would get an OrderSend Error 3 message in your experts log in MetaTrader 4. This can be a rather frustrating error because it prevents the order from executing (and the position from opening). If you are an MQL4 coder, you should learn how to fix it because it signifies that there is an error in the logic of your expert advisor. If you are just a Forex trader, then there are some simple steps that you can follow to fix this error if you have an .mq4 file of the EA. Here you will find out why OrderSend Error 3 occurs and how to fix it in MetaTrader 4.

The OrderSend Error 3 is called ERR_INVALID_TRADE_PARAMETERS (invalid trade parameters) internally in MT4 platform.

Why does OrderSend Error 3 appear?

ERR_INVALID_TRADE_PARAMETERS means that some of the parameters passed to OrderSend() function aren't correct. By the way, this error may also appear with the OrderModify() function (appears as OrderModify Error 3). The most popular cases are the following:

  1. Incorrect operation type passed to the OrderSend() function. Remember that there are only 6 operation types available in MetaTrader 4.
  2. Negative slippage passed to the OrderSend() function. Remember that slippage can only be 0 or greater.
  3. Incorrect order ticket passed to the OrderModify() function. Make sure the order with the given ticket exists in the system before calling this function.

How to fix OrderSend Error 3?

So, what can you do when you spot this OrderSend Error 3? First, check that the operation passed to the function is one of the following:

  1. OP_BUY (Open long position).
  2. OP_SELL (Open short position).
  3. OP_BUYLIMIT (Buy limit order).
  4. OP_SELLLIMIT (Sell limit order).
  5. OP_BUYSTOP (Buy stop order).
  6. OP_SELLSTOP (Sell stop order).

Then make sure that the slippage passed to the OrderSend() function isn't negative. Slippage is often given as an input parameter, so you just enter some positive value there. Finally, if the error appears as OrderModify Error 3, make sure that the EA deals with the correct ticket (perhaps, it is trying to use 0 or -1?). Just add this condition in front of the OrderModify() function call in the .mq4 file of the expert advisor:

if (ticket > 0)

where ticket is your variable for ticket used in the function. It will cut all attempts to pass the most popular incorrect ticket values.

If you have any thoughts, comments, or questions regarding MT4 Error 3 and the ways to get rid of it, feel free to join a discussion on our Forex forum.