Join our fan page
- Views:
- 99
- Rating:
- Published:
-
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
In Tester during optimisation you may encounter passes crashing due to memory shortage.
There is a method to calculate such emergency passes. However, it is difficult to evaluate all the many variants of input parameters for heavy memory consumption by the Expert Advisor.
You need to find potentially problematic configurations of input parameters of an existing Expert Advisor. And then figure out the causes.
This simple library allows you to track the dynamics of changes in memory consumption in a rather simple way.
Example.
To illustrate, let's take a laconic EA and add a few lines to it (highlighted).
#property tester_no_cache #define MEMORY_TESTER_OPTIMIZATION // Operation in Tester optimisation mode. #include <fxsaber\Memory\Memory.mqh> // Memory Consumption Monitoring. input int inMaxMB = 10; void OnTick() { static MqlRates Rates[]; const int SizeMB = (ArraySize(Rates) * sizeof(MqlRates)) >> 20; if (SizeMB < inMaxMB) ArrayResize(Rates, ((SizeMB + 2) << 20) / sizeof(MqlRates)); // Increase the array by ~megabytes. } double OnTester() { return(gMemory.GetMax()); // Maximum memory consumption during programme execution. }
The Expert Advisor simply increases its array.
Result.
The picture shows the result of the optimisation.

The memory consumption measurements are similar.
A single pass of the top set will produce this.
Core 1 OnTester result 102 Core 1 2026.02.10 23:58:58 MQL_MEMORY_USED: Min = 0 Max = 102 Last = 0 Core 1 EURUSD,M1: 80954 ticks, 1437 bars generated. Environment synchronized in 0:00:00.020. Test passed in 0:00:01.781. Core 1 EURUSD,M1: total time from login to stop testing 0:00:01.801 (including 0:00:00.020 for history data synchronization) Core 1 202 Mb memory used including 23 Mb of history data, 64 Mb of tick data
Scenarios.
The library allows you to find excessive memory consumption by the Expert Advisor and further investigate the causes in debug mode.
The less resources the Expert Advisor consumes, the more opportunities for optimisation: increase in the number of testing agents - speed of optimisation.
Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/69335
RSI Price Action Breakout Indicator
A high-precision trend reversal indicator combining RSI exhaustion zones with candlestick breakout patterns.
ExMachina Telegram Bridge
Connect your MetaTrader 5 account to Telegram. Receive instant notifications every time a trade opens, closes, or gets modified — directly in your phone. This is a notification-only Expert Advisor. It does not place, modify, or close any trades. It monitors your account activity and sends formatted messages to your Telegram chat via the Bot API.
Accelerator Oscillator (AC)
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.
MACD Signals
Indicator edition for new platform.