Guarda come scaricare robot di trading gratuitamente
Ci trovi su Twitter!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Librerie

Reporting Memory Leaks in Strategy Tester - libreria per MetaTrader 5

Visualizzazioni:
2843
Valutazioni:
(7)
Pubblicato:
2023.08.12 12:15
Aggiornato:
2023.08.12 15:33
Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

The strategy tester does not report any memory leaks of MQL5 applications like expert advisors, scripts or indicators. And such memory leaks can occur by using the  new operator in your MQL5 code and forgetting to free the occupied memory later in your code by calling the  delete  operator. For example in complex programs with many classes and data collections the  obligatory usage of the  delete  operator can be overseen very easily, and it can be difficult to trace such problems.

In my opinion the strategy tester should not only be used to develop a coherent trading logic, but also to detect software-related problems. Especially for finding memory leaks. The earlier such problems can be found and fixed the better.

Therefore here is presented an include file with name "checker_for_memory_leaks". Dominik Egert made a significant contribution to this file; please look at https://www.mql5.com/en/forum/438987

This header file can be used for Expert Advisors, Scripts and Custom Indicators and should be included at the very beginning of the code. The purpose is to monitor eventually occurring memory leaks during the testing of your application in the strategy tester. Otherwise there is no need to change the actual code. In the header file the operators  new  and  delete  are 'bent' to allow an indication of the leaks that occur eventually. After having thoroughly tested your application and fixed all memory leaks you simply can uncomment/remove the   #include <checker_for_memory_leaks.mqh>   statement in your program.

As an example here a very simple script named  "MemoryLeak.mq5"  using this header is presented:

#include <checker_for_memory_leaks.mqh>

//+------------------------------------------------------------------+
//| Simple class CA without any content                              |
//+------------------------------------------------------------------+
class CA {};
void OnStart()
  {
   CA *a;
   a = new CA;
   if(a == NULL)
     {
      Print("NULL Pointer!");
      return;
     }
// 'forget' to call the delete operator'
// delete a;
  }
//+------------------------------------------------------------------+

The output:

2023.08.12 11:45:26.072 MemoryLeak (.DE40Cash,M15)      -- Resume Memory Leaks --
2023.08.12 11:45:26.072 MemoryLeak (.DE40Cash,M15)      1 undeleted objects left
2023.08.12 11:45:26.072 MemoryLeak (.DE40Cash,M15)        - File MemoryLeak.mq5 Line 10
2023.08.12 11:45:26.072 MemoryLeak (.DE40Cash,M15)      -- End Resume --

You can see in which file and which line the memory has been allocated. This information should make it easier for debugging to find the right place in the program where the memory deallocation should occur

    Trend Dashboard Indicator Trend Dashboard Indicator

    Trend Dashboard Indicator MetaTrader 5 indicator — a multi-timeframe indicator that is based on three standard indicators: Stochastic oscillator, RSI (Relative Strength Index), and CCI (Commodity Channel Index). It displays current trend directions for M1, M5, M15, M30, H1, H4, D1, W1, and MN1 timeframes. When you follow such an indicator you have a clear picture of the trends across all important timeframes. It doesn't matter which timeframe you attach this indicator to. The indicator can be downloaded for MT4 and MT5.

    Moving Average with alerts on price crossovers Moving Average with alerts on price crossovers

    I wanted to build a moving average which would create an alert when the price moves over the line by a user defined amount of points. It creates both bullish and bearish signals depending on the direction of market price moving through the MA. It is designed for slow length moving averages (default is 200-day MA). EDIT: I now added a second version of the indicator which uses Arrow buffers instead of ObjectCreate.

    AllAverages v4.9 MT5 AllAverages v4.9 MT5

    One of the latest version of this indicator at the moment. Huge base of different modifications of moving averages, with multitimesframe function, sending signals to e-mail and push notifications.

    Moving average code for beginners  by William210 Moving average code for beginners by William210

    Moving average beginner tutorial to learn how to code in MQL5