New article Library for easy and quick development of MetaTrader programs (part XXV):
Handling errors returned by the trade server has been published:
After we send a trading order to the server, we need to check the error codes or the absence of errors. In this article, we will consider
handling errors returned by the trade server and prepare for creating pending trading requests.
In the last MetaTrader 5 versions (starting from the build 2201), the tester features the ability to set parameters of a symbol the test
is performed on. Thus, it is possible to set trading limitations on a symbol and test the library behavior when the symbol limitations
To call the symbol settings window, click the button to the right of the tested timeframe selection:
Allow opening long positions only for a symbol and set the volume limitation of simultaneously opened positions and placed pending orders
in one direction to 0.5.
Thus, we will be able to use long positions only and have the maximum total volume of buy positions and orders of no more than 0.5 lot in the
market. In other words, when opening a position with the lot of 0.1, we are able to open five positions only or place a single pending buy
order and open four positions:
For more authenticity, we could disable auto closure of positions when a specified profit is exceeded. However, we can see that we were
unable to open a short position and received the warning that only buy positions are allowed on a symbol. Further on, when trying to open a
number of positions with their total volume exceeding 0.5 lots, we receive the message of the inability to open a position due to
exceeding the maximum total volume of positions and orders in one direction.
Author: Artyom Trishkin