Errors, bugs, questions - page 2941

 
Can you suggest, if any, a way to save previous value of string variable in indicator after Init event? Global variables of the terminal do not work with string. To be exact, at the end of OnCalculate() we need to make prev_val=val and to save prev_val afterInit, while val will take a new value, as usual. But I would not like to create an object on the chart, name it by required name and after Init read the old value. It would be pretty ugly, although it is possible... And the name may be long and objects have a very limited number of names.
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Глобальные переменные - Переменные - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
x572intraday:
Can you suggest, if there is, a way to save previous value of string variable in the indicator after Init event? Global variables of the terminal do not work with string. To be exact, at the end of OnCalculate() we need to make prev_val=val and to save prev_val afterInit, while val will take a new value, as usual. But I would not like to create an object on the chart, name it by required name and read the old value after Init. It would be pretty ugly, although it is possible... And the name may be long and objects have a very limited number of names.

you can use resources and units to store and transfer simple structures or even arrays of simple structures between TFs.

To do this, you will need:

template <typename T>
union
sizeof(T)
ResourceReadImage
ResourceCreate
ResourceFree
_UninitReason
To store strings, you'll have to use a static uchar array of fixed size. (see CharArrayToString, StringToCharArray).
 
Nikolai Semko:

you can use resources and units to store and pass simple structures or even arrays of simple structures between TFs.

For this you will need:

To store strings you'll have to use a static uchar array of a fixed size. (see CharArrayToString, StringToCharArray).

I also remembered - via files, but I wouldn't want to do that either, as it's not the most natural way to do it.

Thanks, I'll give it a try.

 
x572intraday:

I also remembered using files, but I don't want to do that either, as it's not the most natural way to do it.

Thanks, I'll give it a try.

If SSD, that's a good way too.
 
x572intraday:

I also remembered using files, but I don't want to do that either, as it's not the most natural way to do it.

Thanks, I'll give it a try.

If we are talking about MT5, there is a non-zero probability that OnInit of the new indicator state will be called before OnDeinit of the previous indicator state
 
Slava:
If we're talking about MT5, there is a non-zero probability that OnInit of the new indicator state will be called before OnDeinit of the previous indicator state
Therefore, the data should be saved not at OnDeinit, but immediately after the data changes or according to some event.
OnDeinit can only be left to save to file if the terminal is closed.
 
Nikolai Semko:
Therefore, data saving should not take place at OnDeinit, but immediately after a data change or at some event.
OnDeinit can only be left to save to a file if the terminal is closed.
Yes
 

Is there a function or some other additional functionality (library, code) for saving EA settings?

When you run the EA, save the settings to the standard settings grid.

 
Aleksei Skrypnev:

Is there a function or some other additional functionality (library, code) for saving EA settings?

When you run an EA, save the settings to the standard settings grid.

Here is an example in the description. Search for SaveSet.

SingleTesterCache
SingleTesterCache
  • www.mql5.com
Данные одиночного прохода Тестера.
 

The application has been "Started" in the Service Desk since December.

Probably got lost

Finance: Problem with depositing in MQL5.com account
Open,Launched: 2020.12.28 16:34,#2929416
Reason: