OrderSend Error 131 is a very popular problem that is usually encountered when testing MT4 expert advisors. What causes this error? Its called ERR_INVALID_TRADE_VOLUME in the MT4 code. That means that your expert advisor is trying to send an order with invalid trade volume. On the absolute majority of the MT4 brokers setting some EA to open an order 0.123 lots will generate this error. But sometimes its generated when the EA, created for mini or micro accounts, is used on the standard account. If you stumble on OrderSend Error 131 during your testing, you can quickly find out the wrong settings of your EA — find the standard init() function inside your EAs code and insert these lines of code there:
Print(MarketInfo(Symbol(), MODE_LOTSIZE));
Print(MarketInfo(Symbol(), MODE_MINLOT));
Print(MarketInfo(Symbol(), MODE_LOTSTEP));
Print(MarketInfo(Symbol(), MODE_MAXLOT));
The first line will give you the information regarding how many units one lot holds when you trade in this account (100000 would mean a
For example, demo account at FXOpen generates this info when I insert those lines into the code:
2008.07.10 15:13:37 MACD Sample EURUSD, H1: 10000
2008.07.10 15:13:37 MACD Sample EURUSD, H1: 0.01
2008.07.10 15:13:37 MACD Sample EURUSD, H1: 0.01
2008.07.10 15:13:37 MACD Sample EURUSD, H1: 100000
That means that 1 lot is 100,000 units (a standard size), minimum trade volume is 0.01 lot (so, one can trade starting from $10 on 1 position in a
You can incorporate the MarketInfo() function at a more complex level into your EA, so it could automatically check the allowed values and correct its settings. But if you dont want to code much, you can just use the code above to find out the right values and correct the settings manually.
- admin_mm
- July 10, 2008
- zero comment