Download MetaTrader 5
To add comments, please log in or register
Enable MQL5 Storage to store your source codes. It is free!
user_123
172
user_123 2014.03.13 18:24 

Dear Community,

is there a possibilty to set the Index Buffer in a for loop? Something like this:

   for(int i=1;i<40;i++){
      SetIndexBuffer(i,HighLineBuffer&i);   
   }

Unfortunately, the code will not compile. Do I really need to write everything individually?



Thank you for your help

Alain Verleyen
Moderator
28695
Alain Verleyen 2014.03.13 19:01  
user_123:

Dear Community,

is there a possibilty to set the Index Buffer in a for loop? Something like this:

Unfortunately, the code will not compile. Do I really need to write everything individually?



Thank you for your help

Yes it's possible but not this way. You have to use an array, but as a buffer as already an array and SetIndexBuffer doesn't allow multidimensional array :

struct Buffer
  {
   double buffer[];
  };

Buffer indi[40];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   for(int i=1;i<40;i++){
      SetIndexBuffer(i,indi[i].buffer);   
   }   
//...
  }
/
To add comments, please log in or register