Discussion of article "Library for easy and quick development of MetaTrader programs (part XXXI): Pending trading requests - opening positions under certain conditions"
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
New article Library for easy and quick development of MetaTrader programs (part XXXI): Pending trading requests - opening positions under certain conditions has been published:
Starting with this article, we are going to develop a functionality allowing users to trade using pending requests under certain conditions, for example, when reaching a certain time limit, exceeding a specified profit or closing a position by stop loss.
This library functionality allows users to programmatically create conditions, under which a trading order is sent to the server.
For example:
The examples are simple but there may be plenty of conditions and their combinations. At this stage, we are going to develop control over changes in properties of accounts, symbols and events occurring on the current account. The conditions from these three lists can be set in any combination.
We will start from a simple thing — controlling changes of symbol and account property values. This will be followed by controlling account events and reacting to them.
To let a pending request object work as part of a trading logic (sending trading orders under conditions), we need to implement additional data into this object to store pending request activation conditions and methods of their control and handling. The data storage is to be made in the form of a two-dimensional array. The first dimension is to store a condition number (there may be as many conditions as necessary), while the second one is to contain all data of the condition whose number is specified in the first dimension — condition source type (symbol, account or event), condition itself (create enumerations for each of the sources), comparison method (>,<,==,!=,>=,<=), reference value of a tracked property and its current value.
Author: Artyom Trishkin