Download MetaTrader 5

Variable name for variable

To add comments, please log in or register
Start making profit using the Market. Publish your product!
Esse
8
Esse 2016.11.19 11:56 

Hey

how reduce this code:

a1  = ...
a2  = ...
a3  = ...
...
a24 = ...


for example:


for(int i=0; i<25; i++)

   {ai = ... ; } // a1, a2, a3 .. a24
Alain Verleyen
Moderator
30754
Alain Verleyen 2016.11.19 12:40  
Esse:

Hey

how reduce this code:

a1  = ...
a2  = ...
a3  = ...
...
a24 = ...


for example:


for(int i=0; i<25; i++)

   {ai = ... ; } // a1, a2, a3 .. a24
With an array.
Esse
8
Esse 2016.11.19 13:16  
Alain Verleyen:
With an array.

Thank you.


   string strArray[]={"a1", "a2", "a3", "a4", "a5","a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15","a16", "a17", "a18", "a19", "a20", "a21", "a22", "a23","a24"};  
   for(int i=0; i<25; i++)
      {
      strArray[i] = Close[i]; //   <== ai
      Print( strArray[i] );
      }
To add comments, please log in or register