Theory of EA acceleration when using a custom indicator (function - iCustom) - page 6

 

Alexander Laur, i.e. as long as the script/advisor is running the memory is reserved and cannot be cleared - sad conclusion.
Is it possible for the script to run another script, then closing the script running should cause the memory to be cleared, or would that be considered as a complex processing environment?

 
-Aleks-:

Alexander Laur, i.e. as long as the script/advisor is running, the memory is reserved and cannot be cleaned - sad conclusion.
Is it possible to run another script, then closing the script running should result in memory clearing, or will it be regarded as a complex data processing environment?

I immediately suggested"open chart with Expert Advisor running", it can be done - ChartOpen + ChartApplyTemplate

The only question is whether the memory will be freed when closing it (deleting the Expert Advisor).

Check it.

 
Andrey Khatimlianskii:

I immediately suggested"open chart with Expert Advisor running", it can be done - ChartOpen + ChartApplyTemplate

The only question is whether the memory will be freed when closing it (deleting the Expert Advisor).

Check.

I have tried it manually, changing the template with a lot of indicators to almost empty - the effect is there (but the cache remains - I think it's not critical). But how to make opening and closing through a template script - I do not know. I understood that the doubt is that as long as the script is running, the memory will not be cleared... Andrei, please help with the experiment.
 

Additional question, does the choice of the real buffer type for the calculation within the indicator affect the size of the graphical buffer?

Type

Size in bytes

Minimum positive value

Maximum value

Accuracy of representation

Analog in C++

float

4

1.175494351e-38

3.402823466e+38

7 significant digits

float

double

8

2.2250738585072014e-308

1.7976931348623158e+308

15 significant digits

double


And a crazy idea, what if instead of a graphical buffer we use TextOut - just don't know how to read data from it...

 
-Aleks-:

Additional question, does the selection of the real buffer type for the calculation within the indicator affect the size of the graphical buffer?

By "graphical buffer" do you mean the graphical display of a normal indicator?
 
Dennis Kirichenko:
By the term "graphical buffer" do you mean the graphical displaying of a regular indicator?

The question is whether it is possible to affect the size of memory allocated to the graphical buffer by one bar if you use float instead of double in the indicator code for calculations.

//---- buffers

double Vy[];
double bufDirSoft[];

extern int n=3;
extern int BarsN=100;
//----
int ExtCountedBars=0;

 
Also, how can you tell if the memory has run out, are there any functions?
 
-Aleks-:

The question is whether it is possible to affect the size of memory allocated to the graphical buffer by one bar if you use float rather than double in the indicator code for calculations...

No. There is a magic function that will displace all the attempts:

bool  SetIndexBuffer(
   int                    index,         // индекс буфера
   double                 buffer[],      // массив
   ENUM_INDEXBUFFER_TYPE  data_type      // что будем хранить
   );

This mechanism is built into the Terminal language itself. It's an interesting idea, though...

 
-Aleks-:
Also, how can you tell if the memory has run out, are there any functions?

What do you mean run out of memory? :-)

There's something here:

https://www.mql5.com/ru/docs/constants/environment_state/terminalstatus#enum_terminal_info_integer

In my opinion, the most effective way to manage the memory for the indicator resources is to minimize the "Max bars in history" parameter (Settings --> Charts). As far as I remember, the minimum for the parameter is 5k.

Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Состояние клиентского терминала
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Состояние клиентского терминала
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Состояние клиентского терминала - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
-Aleks-:
Also, how can I know if memory is out, are there any functions?

It is possible to retrieve information about the terminal

TERMINAL_MEMORY_TOTAL

Memory size, available to terminal (agent) process, in MB

int

TERMINAL_MEMORY_AVAILABLE

The size of available memory of the terminal (agent) process in MB

int

TERMINAL_MEMORY_USED

Memory size, used by terminal (agent), in MB

int

Reason: