Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 935

 
FxRoller:
Good morning, all! This question: is it possible to shift indexing of array elements by 1 unit without creating one more array like this and element by element, copying information from the first array (and then back) into it? In fact, in MT4 it is somehow done in arrays of timeseries (when a new bar is formed, the index 0 is assigned to it, and the indexes of all previous elements of the array are shifted by 1 unit).

I join the question: it would be convenient to use the built-in function to shift the N dimension of the array by M elements to the right or to the left.

As far as I know, for now you have to shift by a loop, defining the size of the array. It's harder to use dynamic (+data is not lost).

 
kosmos0975:

I join the question: it would be convenient to use the built-in function to shift the N dimension of the array by M elements to the right or to the left.

As far as I know, for now you have to shift by a loop, defining the array size. More difficult to use dynamic(+data is not lost).

Doesn't SetIndexShift() help?

Sets shift of indicator line relative to the beginning of chart.

voidSetIndexShift(
intindex,// number
int shift// shift
);

Parameters

index

[The index number of the line. Must be from 0 to 7.

shift

[in] Shift value in bars.

Returned value

No.

Note

A positive value shifts the line image to the right, a negative value shifts it to the left. The value calculated on the current bar is drawn with the specified offset relative to the current bar.

Example:

 

You can also copy an array to itself with an offset.

int  ArrayCopy(
   void&        dst_array[],         // куда копируем                           // сюда, понятно имя массива
   const void&  src_array[],         // откуда копируем                         // сюда тоже его
   int          dst_start=0,         // с какого индекса пишем в приемник       // сюда 0
   int          src_start=0,         // с какого индекса копируем из источника  // сюда, например с первого, значит 1
   int          count=WHOLE_ARRAY    // сколько элементов                       // сюда размерность массива минус 1
   );

So the array will be copied to itself with an offset of 1 element. Zero will be discarded, and the last one will be empty. On the contrary, discarding the last element, I haven't tried it, but I think you can correctly set the last three parameters of the function.

 
AlexeyVik:

You can also copy an array to itself with an offset.

So the array will be copied to itself with an offset of 1 element. Zero will be discarded, and the last one will be empty. The other way around, throwing out the last element, I haven't tried it, but I think the last three parameters of the function can be set correctly.


I haven't tried it, but it may be useful to change indexing direction.

P.S. I have some questions about strategy tester. Can you help?

 
kosmos0975:

Haven't tried it, but a change in indexing direction might come in handy.

P.S. There are questions about the strategy tester. Can you help?

Do you mean to change indexing direction after copying an array in itself? Is it necessary? I think there will be no problem to copy from zero index without the last one and paste from the first one, while the zero one will remain either empty or the old value, no matter, because this procedure is needed not just for the sake of copying, but specifically to replace one of the array values (zero or last) with a new one. Correspondingly, after such copying, the "vacated" element is filled with the new value. And it doesn't matter what was left in it.

On tester, if I can - I will help. But here there are more worthy who can suggest.

 

The controlling signals and the control of open positions are performed by the indicator. Commands for opening and closing positions are sent to the Expert Advisor through the global variables of the terminal.

The use of indicators is convenient because there are a lot of indicators, and you can see the work of several logical blocks at the same time.

Question. In the strategy tester, the indicator can work with the OrderSelect() function,OrdersTotal(), etc.

 
AlexeyVik:

Do you mean to reverse the direction of indexing after copying the array into itself? Is that really necessary? I think there will be no problem to copy from zero index without the last one and paste from the first one, while the zero one will remain either empty or the old value, no matter, because this procedure is needed not just for copying, but specifically to replace one of the array values (zero or last) with a new one. Correspondingly, after such copying, the "vacated" element is filled with the new value. And it doesn't matter what was left in it.

On tester, if I can - I will help. But here there are more worthy who can suggest.

Before copying and after.
 
I haven't checked, but what prevents you from checking it yourself? You just need to save the template with all indicators under the EA name and then when you start the EA in the tester all indicators will be loaded and probably will work correctly. But it is possible that they will take values from the "Trade" and "Account history" tabs.
 
kosmos0975:
Before copying and after.
Why scratch your right ear with the finger of your left hand? Or foot... I said only that the second option, for want of necessity, has not tested. But logically it would work without any problems.
 
AlexeyVik:
Not checked, but what prevents you from checking it yourself? You just need to save the template with all indicators under the EA name and then when you start the EA in the tester all indicators will be loaded and probably will work correctly. But it is possible that they will take the values from the "Trade" and "Account history" tabs.
I tried it. Not yet. I will try again.
Reason: