Regular Expressions in MQ L5 for working with regular expressions

Regular Expressions in MQ L5 for working with regular expressions
DOWNLOAD all MT5 librarys (393)
YouTube Video Thumbnail

Similar MetaTrader Tools

Regular Expressions in MQ L5 for working with regular expressions

Info

The Regular Expressions in MQ L5 for working with regular expressions is a Library for MetaTrader 5 that microsoft corporation. Source code taken from.

Usage

This tool is typically used for enhancing chart analysis and decision making.

Platform

This Library works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Libraries folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use Regular Expressions in MQ L5 for working with regular expressions

1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.

2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.

3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.

4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.

Frequently Asked Questions

Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.

Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.

Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.

What this tool does

Microsoft Corporation.

Typical Use Case

This Library excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Library works on MetaTrader 5. Place the file in the MQL5/Libraries folder and restart the terminal.

Description & Settings

Related: PN N Neural Network Class - another powerful library for MetaTrader 5 traders.


Microsoft Corporation. Source code taken from .
Note: The library works on the MetaTrader 5 build 1285 and higher.

Also recommended: Easy Neural Network - similar library with strong performance on MetaTrader 5.

Unzip the archive into the . The library codes are located in the: <terminal_data_folder>\MQL5\Include\RegularExpressions\ Sample test scripts can be found in the <terminal_data_folder>\MQL5\Scripts\RegularExpressionsExamples\
Here is a translation of the RegularExpressions from .Net Framework 4.6.1.
To work with the library, include the Regex.mqh file from the "\MQL5\Include\RegularExpressions\" directory in your code.
Several illustrative examples are provided with the library, which at the same time serve as the test cases. All the samples are taken from the official site of , they vividly demonstrate the main differences from the regular expressions in C# and the features of their use in the MQL5.
Below is more detailed information about RegularExpressions MQL5 ported library packages:
The regular expression parameters from the file
RegexOptions.mqh
:
Working with RegularExpressions for MQL5:

The second feature of working with regular expression in MQL5 directly follows from the first one. And it lies in the fact that the above storage must be cleared. To do that, call the
Regex::ClearCache()
static function. It is recommended to call this function only after the work with the regular expressions has been completed, otherwise there is a risk to delete necessary pointers.

Unlike the .Net, the MQL5 does not implement the
foreach
loop, and hence the enumeration handling will be different. Example:

As can be seen from the above example, the C# syntax allows to put the '@' symbol in front of the strings to ignore all formatting marks in it. In MQL5, this approach is not provided, so all control characters in a regular expression pattern should be explicitly defined.
Example of working with RegularExpressions for MQL5:
As an example of regular expressions, consider their application to parse the trading history downloaded from the terminal in the form of an html file.
To do that, create an expert with a single input parameter of the 'string' type, which will be the name of the :
This document contains two main tables: "Orders" and "Deals".
Create a regular expression to parse the file:
Consider this regular expression:
Next, read the file line by line and get all the matches which correspond to this regular expression:
The strings of the html file, that are entries (tuples) for the "Orders" and "Deals" tables, will have the most of such matches, namely 23 and 27 matches respectively. Therefore, the only thing left to do is to extract all the necessary information from these strings.
For the "Orders" table:
It has been confirmed that the number of matches is 23, and therefore, the handled entry is from the "Orders" table. Create a string array as the initial representation of our entry. Create iteration over all the odd matches, get the values of those matches using the
matches[j][.Value()
method, trim the first and the last characters of each match, which correspond to the characters '>' and '<'. Each formatted match is written to a previously declared
in
array. After that create an instance of the
OrderRecord(in)
class, which represents a single entry of the "Orders" table, and add it to the
m_list1
list. This list will interpret the "Orders" table.
The "Deals" table will be processed in a similar way:
Here
m_list2
is a list of pointers to the
DealRecord
class. It represents the "Deals" table.
Both these lists are members of the
TradeHistory
class. This class is the representation of the entire original html file. In addition, it allows to apply simple filters to the "Orders" and "Deals" tables using the methods:
FindAllOrders(const int columnIndex,const T value)
and
FindAllDeals(const int columnIndex,const T value)
.
Create a simple graphical interface in the EA to demonstrate these capabilities:
When working with this form, select the desired table, select a column and its value to filter the table. Press the
Find
button, and the filtered table will be displayed below, along with some statistics on it. The
Save
button stores the currently displayed table to a csv file. The saved file will be located in the sandbox as well, and have the name
Result.csv
.
To learn more about the
RegularExpressions for MQL5
and its features, use the provided
Tests.mqh
expert. It implements numerous examples of regular expression usage, which cover all the main functionality of the library.

You may also like: Class for set and check your trading time - excellent alternative for library users on MetaTrader 5.

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
RobotFX does not own any of the code provided on this platform. All tools are freely available on the internet; we simply index and re-offer them for download. We are not responsible for any financial losses that may occur. Trading responsibilities rely solely on the traders downloading and using the displayed Expert Advisors, indicators, and scripts. These tools are provided for educational purposes only and may require modification or optimization to align with a trader's specific strategy or needs.
© ROBOTFX - Best MetaTrader Expert Advisors & Indicators