[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 873

 
Gravitus:

When trying to write

extern string array[25];

The compiler gives out

'array' - external arrays are not allowed

you need to do without extern.
 
Andrei01:
you need to do without extern.
But then it would no longer be external...
 
Gravitus:
But then he won't be an outsider...
would be
 
Andrei01:
will be
but is there any way to refer to a variable whose name is contained in a string variable?
 
Gravitus:
but is there any way to refer to a variable whose name is contained in a string variable?
you need to number them first.
 
Gravitus:

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;
}
}

 
Andrei01:
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.

 
reag:


the task is to calculate when a new candle arrives

The time of a new candle is Time[0].
 

Andrei01, reag - thank you.

Just thought there were some magic quotes, but okay, switch is fine :)

 
Gravitus:

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);
}