CopyBuffer still perplexing me

 

Try as I might, I just can't wrap my head around CopyBuffer.

Straight from  CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5:

Can someone explain how this is not a transposition?

Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Millard Melnyk:

Try as I might, I just can't wrap my head around CopyBuffer.

Straight from  CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5:

Can someone explain how this is not a transposition?

Can you explain how this is transposed?
 
Millard Melnyk:

Try as I might, I just can't wrap my head around CopyBuffer.

Straight from  CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5:

Can someone explain how this is not a transposition?

Dominik Egert #:
Can you explain how this is transposed?

The array being copied into is in chronological/index order from left to right, with the oldest bar as 0 and the newest as ArraySize(array) - 1;

Reading the indicator buffer chronologically/in index order, we get a sequence of 0,1,2,3,4,5,6,7,8 (right to left).

If CopyBuffer works exactly as the diagram shows, then reading the array chronologically/in index order, we get a sequence of 0,1,2,3,4,8,7,6,5 (left to right).

So, indicator buffer = 0,1,2,3,4,5,6,7,8 vs. array = 0,1,2,3,4,8,7,6,5.

See it?

 
Millard Melnyk #:

The array being copied into is in chronological/index order from left to right, with the oldest bar as 0 and the newest as ArraySize(array) - 1;

Reading the indicator buffer chronologically/in index order, we get a sequence of 0,1,2,3,4,5,6,7,8 (right to left).

If CopyBuffer works exactly as the diagram shows, then reading the array chronologically/in index order, we get a sequence of 0,1,2,3,4,8,7,6,5 (left to right).

So, indicator buffer = 0,1,2,3,4,5,6,7,8 vs. array = 0,1,2,3,4,8,7,6,5.

See it?

Yes. But actually No.

The indicator buffer is just indexed in reverse to to the value you supply to the function.

Actually the array grows at the end, at least in terms of memory. What happens is, from the last valid index, your supplied value is subtracted. By applying this access pattern you will always have the most recent value at "index zero", but actually you are accessing the last valid index in the array.

This way, when copying data, the copy process will work normal inside the terminal, and to you it seems in reverse. But actually it is not.

So in short, the indicator buffer is using AsSeries as it's access pattern.

There is no transposition, it just looks like that.
 
Dominik Egert #:
Yes. But actually No.

The indicator buffer is just indexed in reverse to to the value you supply to the function.

Actually the array grows at the end, at least in terms of memory. What happens is, from the last valid index, your supplied value is subtracted. By applying this access pattern you will always have the most recent value at "index zero", but actually you are accessing the last valid index in the array.

This way, when copying data, the copy process will work normal inside the terminal, and to you it seems in reverse. But actually it is not.

So in short, the indicator buffer is using AsSeries as it's access pattern.

There is no transposition, it just looks like that.

I understand reverse indexing. The diagram shows a transposition.  0,1,2,3,4,5,6,7,8 reversed would be 8,7,6,5,4,3,2,1,0 -- and vice-versa -- no problem. But if you reverse 8,7,6,5,4,3,2,1,0, (reverse indexing, oldest on left), it would not result in 0,1,2,3,4,8,7,6,5 like the diagram shows. I'm going to assume it actually works as you described, not the way the diagram shows.

 
Millard Melnyk #:

I understand reverse indexing. The diagram shows a transposition.  0,1,2,3,4,5,6,7,8 reversed would be 8,7,6,5,4,3,2,1,0 -- and vice-versa -- no problem. But if you reverse 8,7,6,5,4,3,2,1,0, (reverse indexing, oldest on left), it would not result in 0,1,2,3,4,8,7,6,5 like the diagram shows. I'm going to assume it actually works as you described, not the way the diagram shows.

I don't understand what you are trying to say...

The numbers you have put in the blue part are from above, not from that array....

I think you are (or maybe I just don't understand) confusing something.
 
Millard Melnyk #:

I understand reverse indexing. The diagram shows a transposition.  0,1,2,3,4,5,6,7,8 reversed would be 8,7,6,5,4,3,2,1,0 -- and vice-versa -- no problem. But if you reverse 8,7,6,5,4,3,2,1,0, (reverse indexing, oldest on left), it would not result in 0,1,2,3,4,8,7,6,5 like the diagram shows. I'm going to assume it actually works as you described, not the way the diagram shows.

CopyBuffer(...);
//then 
ArraySetAsSeries(true);

That way everything is in order