How to make bool name ?

 

I want to make below code (difine)

bool LIST_EURUSD;

bool LIST_GBPUSD;


...... many pairs


string list =[EURUSD,GBPUSD, .....];
for(int W=0; W<list.length; W++)
{
bool "LIST_"+list[w];

}

 

 Something wrong with it.

Can you point it out??

 
Cromo:

I want to make below code (difine)

bool LIST_EURUSD;

bool LIST_GBPUSD;


...... many pairs


 Something wrong with it.

Can you point it out??

you cannot create variable names like that...

Best to use an array of type bool instead.

You can use enumeration to provide a friendly reference.

#property strict

enum PAIRS {EURUSD,GBPUSD,EURJPY,USDJPY};   
bool ListPair[4];

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{ 
  
   ListPair[EURUSD] = true;
   ListPair[GBPUSD] = false;
   
}

so in this example  you can use the enum as a ref to the index of the array. 

the enum translation is as follows:  EURUSD = 0, GBPUSD = 1  etc...

 
Paul Anscombe:

you cannot create variable names like that...

Best to use an array of type bool instead.

You can use enumeration to provide a friendly reference.

so in this example  you can use the enum as a ref to the index of the array. 

the enum translation is as follows:  EURUSD = 0, GBPUSD = 1  etc...

wow!!!

Thank you so much.

 
Cromo:

wow!!!

Thank you so much.

you are welcome