Discussing the article: "MQL5 Trading Toolkit (Part 5): Expanding the History Management EX5 Library with Position Functions"

 

Check out the new article: MQL5 Trading Toolkit (Part 5): Expanding the History Management EX5 Library with Position Functions.

Discover how to create exportable EX5 functions to efficiently query and save historical position data. In this step-by-step guide, we will expand the History Management EX5 library by developing modules that retrieve key properties of the most recently closed position. These include net profit, trade duration, pip-based stop loss, take profit, profit values, and various other important details.

In the previous article, we began developing the primary functions of the HistoryManager EX5 library, which forms the core engine responsible for retrieving, sorting, and categorizing historical data into various types, including orders, deals, pending orders, and positions. Most of these functions were designed to operate in the background, unnoticed by the library's users, and were not directly accessible. The only exportable functions were the print functions, which allowed users to output simple descriptive lists of orders, deals, pending orders, or positions to the MetaTrader 5 log.

In this article, we will expand the HistoryManager.mq5 source code by introducing additional user-accessible functions that build upon the foundational ones we created in the previous article. These new functions will allow library users to effortlessly query trade history data. Users will be able to retrieve key details, such as the trade duration in seconds, opening and closing deal tickets of the last closed position, whether the position was initiated by a pending order or a direct market entry, pip-based metrics like profit, stop loss, and take profit, as well as the net profit after accounting for expenses such as commissions and swaps. All of this will allow you to import the EX5 library in your MQL5 projects and be able to query various positions' history with minimal effort through straightforward function calls.

Expanding the History Management EX5 Library with Position Functions

Author: Kelvin Muturi Muigua