Can I number a buffer with a variable?

 

I have a few buffers and numbering them gets tedious because I keep adding or removing ones, so I have to change all their Identifying numbers as I add or remove  buffers


for instance I have

SetIndexBuffer(1,A);

SetIndexBuffer(2,B);

SetIndexBuffer(3,C);


and If I remove  SetIndexBuffer(2,B); , then I need to manually change C, by numbering 2 instead of 3.


I tried with a variable like


int number_buff =0;


SetIndexBuffer( number_buff +1 ,A);

SetIndexBuffer( number_buff + 2,B);

SetIndexBuffer( number_buff + 3,C);


Metaeditor compiles it fines, but MT4 says ''array out of range'' in the ''experts'' tab of the terminal. So what is the fast way of defining a buffer when I remove or add ones ?

 
Enau: I have a few buffers and numbering them gets tedious because I keep adding or removing ones, so I have to change all their Identifying numbers as I add or remove  buffers. So what is the fast way of defining a buffer when I remove or add ones ?
int BufIdx = 0;

SetIndexBuffer( BufIdx++, A );
SetIndexBuffer( BufIdx++, B );
SetIndexBuffer( BufIdx++, C );
SetIndexBuffer( BufIdx++, D );
Now you can change order or remove or add, and it will always number them incrementally.