Math Ticker - tick generator in mathematical mode
Info
The Math Ticker - tick generator in mathematical mode is a Library for MetaTrader 5 that alternative for eatomath libraryrecords ticks in real ticks mode and reads them in maths mode calling your strategy with each recorded tick. Differences from EAToMath: Pros:The code is shorter and simpler, only 5 plug-in libraries.
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 Math Ticker - tick generator in mathematical mode
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
Alternative for EAToMath libraryRecords ticks in real ticks mode and reads them in maths mode calling your strategy with each recorded tick.
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: A cross-platform library of original mathematical functions - another powerful library for MetaTrader 5 traders.
Also recommended: Math Utils - similar library with strong performance on MetaTrader 5.
Alternative for EAToMath libraryRecords ticks in real ticks mode and reads them in maths mode calling your strategy with each recorded tick.
Differences from EAToMath:
Pros:
The code is shorter and simpler, only 5 plug-in libraries. If you need to modify it, it will be easier to understand.
Data are compressed better due to a different algorithm . When saving only time_msc, ask and bid - up to 86% of ticks are saved as 3 char numbers, i.e. 3 bytes. Average size per tick = 3.266 Bytes when saving BTCUSDT tick data for 2023. When saving with volumes average = 4.835 Bytes. And when saving full tick = 8.439 Bytes. Below is the table with the test results. Additionally, you can use the built-in ZIP archiving. The file size is reduced by 2 times. Such a file takes 245 Mb, while the sum of file sizes in .tcs for 2023 takes 364 Mb, i.e. compression is 1.5 times better than in MQ. And the speed of tick generation in the maths mode is ~2 times faster. See the table below.
There are more options of saving:
The file can be saved to either SSD or RAM disc by making a link in the system. Files can take up a lot of space and RAM drive may not be enough, so you can choose to save to the primary drive. SSD and RAM read speeds are about the same, I've read that the SSD caches up to 5% of the full capacity of the most frequently requested data. There is a bit of wear and tear on the SSD when reading, as you have to overwrite memory cells more often than when storing without reading. I don't know the exact numbers, but for example 1 overwrite per 10 reads or per 1000 reads.... But this is of little significance compared to the wear of the disc by the MQ tester.
Cons:
Connecting Virtual has to be done yourself (instructions here , EAToMath will pass your strategy to Virtual itself.
The speed for the BidAsk variant is comparable to EAToMath. Other variants are slower because they either contain more data or have additional ZIP compression.
Usage Features:
You cannot use the standard functions
Symbol()
,
Digits(
) (=4),
Point()
(=0.0001) in the strategy, as they will produce default values, not related to the symbol under test. Instead of them use
_Symbol
,
_Digits
,
_Point
which are overridden on values read from the file. Also, new constants
_TickSize
and
_TickValue
with values from the recorded symbol have been added - they are necessary for correct calculation of profit, commission and swaps in the deposit currency.
The order of work with the testing period selected when saving ticks:
Select the testing mode by real ticks, the required instrument and testing dates. Set the Task variable to one of Save and select the option of saving ticks. Start the tester. After that a file with ticks will be created in the specified folder.
Set the Task variable to
Run_Strategy
. You can leave the mode by real ticks to compare later. Start the tester. Calculations are made by real ticks, not from the file. Get the result.
Set the testing mode to mathematical calculations. Start the tester. Calculations are made by ticks from the file. Compare with the result from step 2. It should be the same, but several times faster.
The order of work with the archive:
Create an archive with all ticks from the history:
Select the mode of testing by real ticks, the required instrument. Set testing dates from <= first tick to >= last tick in the available history. Set the Task variable to one of
Save...To_Archive
and select the option of saving ticks. Start the tester. After that a folder with the name of the tool will be created in the specified folder where the files with ticks for each year will be saved. The last year can be overwritten as necessary, for this purpose select only the current year in the dates to avoid overwriting the previous years.
Set the test mode to Maths. Set the Task variable to
Run_Strategy_Fron_Archive
.
In the
MathTicker: using the full archive
group, set: Instrument - to Instrument name (must match the name of the folder where its ticks are stored), start and end date of the test.
Start the tester. Calculations are made by ticks from the required annual files. Due to the fact that the work is done not with one file, but with several, it is a little slower, because it takes time to open and close files. For example, instead of 1.7 seconds it will take 2.7 seconds to generate ticks for 3 years.
The sum of ticks obtained by the Expert Advisor below may differ by a small value of one first tick. When testing on custom characters in real ticks mode, the first tick produces only Ask or Bid (if you didn't save both). When testing from archive, they are both restored from previous ticks.
An example of the simplest Expert Advisor to estimate the speed of work:
You can toggle 1 setting:
//#define RestoreFlags // восстановить флаги тика из изменения ask, bid, volume - добавит 7% к времени генерации тиков 931 вместо 869 мс
When generating ticks, statistics about tick compression will be displayed. Below are printouts of statistics, volumes and time of tick generation.
----------- MQ
tester without volumes
pass 1 returned result 4345830621850.311523 in
0:00:08.232
MQ tester with volumes
pass 1 returned result 4345879117123.356445 in
0:00:07.962
The size of the .tcs files for the same year 2023:
All variants with ZIP, even full tick saving are more compact (3.5 to 1.5 times).
Expert Advisor example for virtual trading and report output:
This example creates 2 virtual machines with different trading. On even hours one tester is buying, the other one is selling on odd hours.
It is a complex example with 2 testers, it can be simplified if you need to work with one tester.
You can also select the MQ tester and compare it with the results of virtual testers to control the correctness of calculations. Only the commission may not coincide, because there are many different commissions, and only one variant is programmed in the virtual tester.
You may also like: EA To Math - 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.