Forex Blog

First-hand Forex trading experience and information about foreign exchange market that will be useful to traders


OrderSend Error 3

June 2, 2010 by

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 position from opening). If you are an MQL coder you should learn how to fix it because it signifies that there is error in the logic of your expert advisor. If you are a simple Forex trader then there are some simple steps that you can do to fix this error if you have an .mq4 file of the EA. Here you’ll find out why OrderSend Error 3 occurs and how to fix it in MetaTrader.

The OrderSend Error 3 is called ERR_INVALID_TRADE_PARAMETERS internally in MT4 platform. 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 OrderModify() function (appears as OrderModify Error 3). The most popular cases are the following:

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

So what to 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 number (maybe it’s trying to use 0 or -1). Just add this condition in front of the OrderModify() function in .mq4 file of the expert advisor:

if (ticket > 0)

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

If you have any thoughts, comments or questions regarding MT4 Error 3 and the ways to treat it, feel free to reply to this post using the form below.

2 Responses to “OrderSend Error 3”

  1. Steph


    I use this to open orders :

    OrderSend(Symbol(), OP_BUYSTOP, volume, prix, slippage, (prix – Pts_Stop), (prix + Pts_Limit), “Rebond haussier”, iMagic, (TimeLocal()+300), Green);

    It seam to works fine but if I backtest the script I’ve got “OrderSend Error 3”.

    Any idea why it works “live” but doesn’t work with backtesting ?

    Thank you.


    Andriy Moraru Reply:

    It is hard to say without seeing the complete source code of the EA. Did you try running the backtest without expiration parameter in OrderSend()? I mean with ‘0’ instead of ‘(TimeLocal()+300)’?


Leave a Reply

required (will not be published)