[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 640

 
evillive:

Applied in an indicator or EA? Although SetIndexBuffer seems to be applied only in indicators...
In an indicator.
 
TarasBY:
The array in your mentioned function doesn't have to be a buffer, BUT, when using a "non-buffer" array, don't forget to initialize it (specify its dimensionality - ArrayResize(array, n)) or directly when declaring it - double array[n].

This is what I usually do.

ArrayResize(array, Bars); ArrayInitialize(array, 0);

Bars - when you do not know what size the array will be. May it be an error here?

 
Fox_RM:

This is what I usually do.

ArrayResize(array, Bars); ArrayInitialize(array, 0);


Not a good habit. This is what MT does, if you do everything correctly in the indicator
 
Vinin:

Not a good habit. MT does this if you get it right in the indicator

What's the right way to do it? If I declare and initialise the array myself. It's just that sometimes I don't want to load buffers or there aren't enough of them.

By the way, additional question) What to do if there are not enough buffers?

 
Fox_RM:

What's the right way to do it? If I declare and initialise the array myself. It's just that sometimes I don't want to load buffers or there aren't enough of them.

By the way additional question) What to do if there are not enough buffers?


I've only had one case where the internal (indicator) buffers were not enough. I made an auxiliary indicator. However, after optimizing the calculations the need for it, as well as the indicator itself, disappeared. This was the first variant of Hal's indicator that I made
 
Fox_RM:

What's the right way to do it? If I declare and initialise the array myself. It's just that sometimes I don't want to load buffers or there aren't enough of them.

By the way additional question) What to do if there are not enough buffers?


Something like this: If not enough
   Bar=0; 
   for(i=0; i<limit; i++)
       {
       ArrayResize (array, Bar+1);
       .............;
       Bar++;
       }
 
Vinin:


Why do you think so, or did someone tell you this nonsense?

You can always solve it if you have to.

Of course I do, that's why I'm here.
 
b_o_l_t:
Of course you do, that's why I'm here.

Send the whole code in your email, maybe you'll get something.
 

Is there any way to indicate the spread of values?

Example

if (OrdersTotal()==от X до Y)
 
LuckyStrike: Is there any way to indicate the spread of values?

You must mean a construction like this?

if(a>X && a<Y);// условие истинно если a в пределах [X;Y]
If you need to analyse open orders, the code will be more complicated there
Reason: