Without knowing the name, and without any distinguishing features, this cannot be done. You can, for example, get the names of all variables equal to 5 and print their names, found, printed. Or names of all string variables. But in any case it is a variable enumeration.
Yes, it's also a question of selecting a variable by name.
For example, there are variables a1, a2, a3, a4, a5, etc. You have to search through these variables too, choose which one has "a" and 5, and use it.
then there is almost no way. Variable names are only accessible from the preprocessor (#macros).
We must change the internal logic, e.g. use an object hash array of names instead of variables. Then both key and value are available at once. Or use SQLite in case of long term storage. Or combine them :-)
But it is so, without knowledge of algorithm, advice in vain.
Good day all! My question is about MT4 tester, mql4 language Please tell me what is my mistake when initialising an array. I have created a one-dimensional array with 750 elements. I initialized all 750 elements with value 50.0.
It means that on the first and following ticks, the first array item with index 0 must have value 50.0 and the last array item with index 749 must have value 50.0.
In fact it turns out that the last array item has value 0. And the first one, as it should be, is 50.0.
The question. How to make all values of the array (including the last one) have value 50.0 after initialization
Here is my code
double S_L[750]={50.0};
void OnTick()
{
if (Day()==4&&Month()==1&&Year()==2010&&Hour()==0&&Minute()==0)
Переменные должны быть объявлены перед их использованием. Для идентификации переменных используются уникальные имена. Описания переменных используются для их определения и объявления типов. Описание не является оператором. Индексом массива может быть только целое число. Допускаются не более чем четырехмерные массивы. Нумерация элементов массива...
Thanks for the tip. By the way I wanted to clarify..... In Kovalev's tutorial it says that the array can be initialized simultaneously with its declaration (as I did), without any special function. I know that Kovalev's tutorial is somewhat outdated. Q. Do I understand correctly, that now in mql4, arrays should be initialized only using a function?
Функция ArrayResize() позволяет задать для массива размер с некоторым запасом для его будущего увеличения без физического перераспределения памяти. Это сделано для улучшения быстродействия, так как операции по распределению памяти...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Greetings. Could you please tell me something?
Is it possible to get the name of a variable instead of its value? For example, print a variable name.
#define PRINTVAR(x) Print(" " ##x); Print(x)
void OnStart()
{
long anyvar=(long)TimeLocal();
PRINTVAR(anyvar);
}
result:
2020.08.24 14:46:05.394 test (USDCHF,H1) anyvar
2020.08.24 14:46:05.394 test (USDCHF,H1) 1598280365
Possibly a feature from unpublished :-) similar to "C", but not yet usable
You need to get the name of the variable itself.
Without knowing the name, and without any distinguishing features, this cannot be done. You can, for example, get the names of all variables equal to 5 and print their names, found, printed. Or names of all string variables. But in any case it is a variable enumeration.
Maxim Kuznetsov Thanks
Yes, it's also a question of selecting a variable by name.
For example, there are variables a1, a2, a3, a4, a5, etc. You have to search through these variables too, choose which one has "a" and 5, and use it.
then there is almost no way. Variable names are only accessible from the preprocessor (#macros).
We must change the internal logic, e.g. use an object hash array of names instead of variables. Then both key and value are available at once. Or use SQLite in case of long term storage. Or combine them :-)
But it is so, without knowledge of algorithm, advice in vain.
Yes, it's also a question of selecting a variable by name.
For example, there are variables a1, a2, a3, a4, a5, etc. We need to enumerate these variables too, choose which one has "a" and 5, and use it.
Write the names in an array and go through the array.
Good day all! My question is about MT4 tester, mql4 language
Please tell me what is my mistake when initialising an array. I have created a one-dimensional array with 750 elements. I initialized all 750 elements with value 50.0.
It means that on the first and following ticks, the first array item with index 0 must have value 50.0 and the last array item with index 749 must have value 50.0.
In fact it turns out that the last array item has value 0. And the first one, as it should be, is 50.0.
The question. How to make all values of the array (including the last one) have value 50.0 after initialization
Here is my code
Print("=========================749======= ",S_L[749]," =0= ",S_L[0]);
}
At the bottom of the Print() value from the journal
2020.08.24 17:43:55.427 GBPUSD,M1: 52255 tick events (1440 bars, 53256 bar states) processed in 0:00:00.047 (total time 0:00:02.422)
2020.08.24 17:43:55.407 2010.01.04 00:00:53 TESTER(B.ORG) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:52 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:50 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:47 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:45 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:43 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:41 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:40 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:37 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:35 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:32 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:30 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:28 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:26 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:25 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:22 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:20 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:17 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:15 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:13 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:11 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:10 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:07 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00:05 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:02 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.407 2010.01.04 00:00 TESTER(B.ORD) GBPUSD,M1: =========================749======= 0 = 0= 50
2020.08.24 17:43:55.385 2010.01.01 00:00:00 Tester(B.ORD.) test started
Thanks for the help
Here's mine.
Where?))
Where?)))
At the top in my edited post. Thanks for the response.
ANDREY:
Question. How can I make all values of my array (including the last one) have a value of 50.0 after initialisation?
Thanks for the tip. By the way I wanted to clarify..... In Kovalev's tutorial it says that the array can be initialized simultaneously with its declaration (as I did), without any special function. I know that Kovalev's tutorial is somewhat outdated. Q. Do I understand correctly, that now in mql4, arrays should be initialized only using a function?
Thank you.