referencing by some means a group of chart buffers without a case or similar statement

 
string currencyNames[] = {"EUR", "USD", "GBP"};
double EurBuff[ ], UsdBuff[ ], GbpBuff [];

the code above is an example of the variables I need to link in someway to avoid the time wasteful case statement below


Like 

bool  SetIndexBuffer(
   int                    index,         // buffer index
   double                 buffer[],      // array
   ENUM_INDEXBUFFER_TYPE  data_type      // what will be stored
   );
 I need a GetIndexBuffer()


want to optimize this code that passes in a buffer number num

void CurrencyPairs::UpdateBuffers(int num, double perc, int pos, bool isQuotePair ){

   if( isQuotePair ) perc = 1 / perc;

   //Print("num ", num, " delta ", perc, " index ", pos );
   
   switch(num)
   
     {
     
      case 0:
 
         EURBuffer[pos] *= perc;

         break;
      case 1:
    
         GBPBuffer[pos] *= perc; 

         break;        
      case 2:
     
         AUDBuffer[pos] *= perc;  

         break;        
      case 3:
   
         NZDBuffer[pos] *= perc; 

         break;       
      case 4:
   
         USDBuffer[pos] *= perc; 

         break;      
      case 5:

         CADBuffer[pos] *= perc;  

         break;       
      case 6:
    
         CHFBuffer[pos] *= perc;  

         break;         
      case 7:

         JPYBuffer[pos] *= perc; 

         break;       
      default:
         
         Print(" UpdateBuffers ...shouldnt be here  ");
         
         break;
     
     }
     
}
 
rob:

the code above is an example of the variables I need to link in someway to avoid the time wasteful case statement below


Like 

 I need a GetIndexBuffer()


want to optimize this code that passes in a buffer number num

Use a class to wrap the buffer arrays, each object holding one array.

Create an array of objects containing the buffer arrays.

Use the buffer_num to access the object array.
 
rob:

the code above is an example of the variables I need to link in someway to avoid the time wasteful case statement below

Like 

I need a GetIndexBuffer()

want to optimize this code that passes in a buffer number num

You can try the array-of-buffers solution (see IndBufArray.mqh) from the algotrading book.
MQL5 Book: Multicurrency and multitimeframe indicators / Creating application programs
MQL5 Book: Multicurrency and multitimeframe indicators / Creating application programs
  • www.mql5.com
Until now, we have considered indicators that work with quotes or ticks of the current chart symbol. However, sometimes it is necessary to analyze...
 
Dominik Egert #:
Use a class to wrap the buffer arrays, each object holding one array.

Create an array of objects containing the buffer arrays.

Use the buffer_num to access the object array.

Why I didn't think of this is beyond me!

It worked thanks


class CBufferObj : public CObject {

public:

   int    SymID;
   string sSymID;
   double buff[];

   CBufferObj(int i, string sym) {
      SymID = i;
      sSymID = sym;
   }

   ~CBufferObj() {}

};


class CCurrencyList: public CArrayObj {

public:

   void CCurrencyList();

   void ~CCurrencyList();

};




//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
void CCurrencyList::CCurrencyList() {

   for (int i = 0; i < ArraySize(sCurr); i++) {
      CBufferObj* b = new CBufferObj(i, sCurr[i]);
      this.Add(b);
   }
}
 

Stanislav Korotky #:
You can try the array-of-buffers solution (see IndBufArray.mqh) from the algotrading book

indicator output I've been playing with 

having looked briefly at what you recommended it is clear I would have saved a lot of time if I had read that first. I went the hard way and learned a lot along the way