The EOP for schoolchildren. - page 8

 
Then why this approach is not practiced? For some reason the vast majority of those who write indicators even reverse the indexing of arrays as in mql4.
 
Сергей Таболин:

Can I have an example?

Wait a bit, I'll post it here in the Code Base. Otherwise the link to my site will be deleted anyway.

 
Alexey Viktorov:
Then why isn't this approach practiced? For some reason the vast majority of those who write indicators even reverse the indexing of arrays as in mql4.

Because they never wrote complex but fast indicators, otherwise left-to-right indexing would have been a very important task.

 
Alexey Viktorov:
Then why isn't this approach practiced? For some reason the vast majority of those who write indicators even reverse the indexing of arrays as in mql4.

Because they never wrote complex but fast indicators, otherwise left-to-right indexing would have been a very important task.

 
Dmitry Fedoseev:

Because they never wrote complex but fast indicators, otherwise left-to-right indexing would be the solution to a very important problem.

What's the downside of indexing to the right, from the newest one?

 
Dmitry Fedoseev:

Because they never wrote complex but fast indicators, otherwise left-to-right indexing would have been the solution to a very important problem.

There is no difference in the speed of accessing the element. In one case it is void* first+sizeof(T)*index and in the other it is last-sizeof(T)*index. The front and back methods in containers have a constant complexity. I hope that the fact that arrays in mql are essentially containers isn't questioned.
 
Сергей Таболин:

What is the disadvantage of indexing to the right, from the newest?

If the indicator is calculated from the left to the right, then if some event has occurred, for example, a fractal has formed, you must store the index of the bar with this event (to use it later for some purpose). If the indexing is from the right to the left, we should calculate n=Bars-i and store n and then do the reverse: i=Bars-n. But if you do index from left to right, you should just save the index and use it, it won't change. Since in more or less complicated indicators this is always needed, left-to-right indexing is a big help for indicator developers.

 
Vladimir Simakov:
There is no difference in the element access speed. In one case it is void* first+sizeof(T)*index and in the other case last-sizeof(T)*index. The front and back methods in containers have a constant complexity. I hope that the fact that arrays in mql are essentially containers isn't questioned.

What does this have to do with the speed at which the element is accessed?

 
Сергей Таболин:

Can I give you an example?

Here's an example.

 
Сергей Таболин:

Can I give you an example?

https://www.mql5.com/ru/code/25807

Reason: