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.
The most common cases are the following:
- Incorrect operation type passed to the
OrderSend()function. Remember that there are only 6 operation types available in MetaTrader 4.
- Incorrect order ticket passed to the
OrderModify()function. Make sure the order with the given ticket exists in the system before calling this function.
- Invalid Stop Loss or Take profit values.
- Invalid expiration date and time for the order.
How to fix #
If the error is caused by common cases 1 to 3 the strategy needs to likely be updated in the code to correctly account for certain conditions or a variable may be incorrectly placed in the code.
Invalid expiration date and time for the order #
This error tends to happen more often when using strategies that rely on pending orders and are in the lower timeframes. Most brokers will have a minimum distance in minutes for the expiration date and time. When trading lower timeframes (15 minutes or lower) this minimum distance can be greater than what the EA is wanting to set for the expiration of pending orders, in such cases this error may happen. To solve this, the easiest way is to increase the expiration by 1 candle or more until the error stops happening.
Based on my observations most brokers have 10 to 15 minutes as their minimum expiration time from the orders so setting candles to expire to 2 or higher as corresponding when trading in lower timeframes tends to solve the problem.