Discussion of article "Library for easy and quick development of MetaTrader programs (part XXXIII): Pending trading requests - closing positions under certain conditions"

 

New article Library for easy and quick development of MetaTrader programs (part XXXIII): Pending trading requests - closing positions under certain conditions has been published:

We continue the development of the library functionality featuring trading using pending requests. We have already implemented sending conditional trading requests for opening positions and placing pending orders. In the current article, we will implement conditional position closure – full, partial and closing by an opposite position.

Let's compile the EA and test pending requests in relation to various types of closing positions (partial, full and by an opposite one). To do this, launch the EA in the visual tester and do the following:

  1. open a sell position and create a pending request for closing it partially by price;
  2. after the partial closure, open a buy position and create a pending request for closing it by the opposite one (the half-closed short position) by price;
  3. after the partial closure of the long position by the opposite sell one, create a new pending request for the full closure of the long position under the condition that the request is activated by time.


As we can see, all requests are handled according to the given conditions and are removed after activation.

Author: Artyom Trishkin

Artyom Trishkin
Artyom Trishkin
  • www.mql5.com
Trader's profile
Reason: