Dear gurus, please advise how to find a solution to this simple problem:
The input to the script is 25 external string variables named XXXXXX_counter, where the counter is a natural number 1,2,3... 25
the script body should process these variables in a loop for ( i=1 ; i<=25 ; i++ ){...}
I can't figure out how to refer to the corresponding variable in the loop body, getting its name using the i counter
an array would be nice, but external arrays are not allowed....
the problem ultimately boils down to referring to a variable whose name is contained in a string variable.
Respectfully, Gravitus
Better via global variables: for (i=0; i<=3; i++) { switch(i) { case 1 : ixxxxx=DoubleToStr(i,0); XXXXX="XXXXX_"+ixxxx; XXXXX_1=GlobalVariableGet(XXXXX); }
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.
When trying to write
extern string array[25];
The compiler gives out
'array' - external arrays are not allowed
you need to do without extern.
But then he won't be an outsider...
will be
but is there any way to refer to a variable whose name is contained in a string variable?
Dear gurus, please advise how to find a solution to this simple problem:
The input to the script is 25 external string variables named XXXXXX_counter, where the counter is a natural number 1,2,3... 25
the script body should process these variables in a loop for ( i=1 ; i<=25 ; i++ ){...}
I can't figure out how to refer to the corresponding variable in the loop body, getting its name using the i counter
an array would be nice, but external arrays are not allowed....
the problem ultimately boils down to referring to a variable whose name is contained in a string variable.
Respectfully, Gravitus
You could do something like this
for (i=0; i<=3; i++)
{
switch(i)
{
case 1 :
XXXXX_1=i;
case 2 :
XXXXX_2=i;
{ case 3 :
XXXXX_3=i;
break;
default: break;
}
}
Instead of IndicatorCounted() write what you need.
The task is to perform calculations at the arrival of a new candle
The check of Bars- IndicatorCounted() (amount of calculated bars) only changes in the indicator, the main calculation is performed.
the task is to calculate when a new candle arrives
Andrei01, reag - thank you.
Just thought there were some magic quotes, but okay, switch is fine :)
Dear gurus, please advise how to find a solution to this simple problem:
The input to the script is 25 external string variables named XXXXXX_counter, where the counter is a natural number 1,2,3... 25
the script body should process these variables in a loop for ( i=1 ; i<=25 ; i++ ){...}
I can't figure out how to refer to the corresponding variable in the loop body, getting its name using the i counter
an array would be nice, but external arrays are not allowed....
the problem ultimately boils down to referring to a variable whose name is contained in a string variable.
Respectfully, Gravitus
for (i=0; i<=3; i++)
{
switch(i)
{
case 1 :
ixxxxx=DoubleToStr(i,0);
XXXXX="XXXXX_"+ixxxx;
XXXXX_1=GlobalVariableGet(XXXXX);
}