Timeseries array indexing using loops in EA without using indicators and oncalculate function - is it possible ? - page 2

 
this topic did not give me any peace and I made the first real measurements. I will try to experiment further, but here are my first results. Let's face it, my hardware is rather mediocre..
I took 50,000 elements into the buffer with the first iteration and if I used the method of adding the last element to the end mentioned above, the iteration time was 0.18 ms on average, while the array was growing all the time +1 element per iteration cycle.
when I used the same sized static buffer containing 50,000 elements (it can be used as a reverse as series, so that the newest 0 element is the first), then the average time spent fluctuated somewhere around 2-4 milliseconds
It shows indeed that in any case mql5 is very fast. When building large systems, it says very clearly that for larger data volumes it is more reasonable to try to avoid the as series function until possible, just try to get the necessary data from the buffer and only then turn it around if necessary before starting to process it further.
I recommend that those who are not planning to build something big ignore this topic at all, because as you yourselves see in this case the differences are only marginal. Other hand , in the case of system-critical and large projects, the differences are very noticeable and it pays to pay attention to it.
 

if you want to do everything directly in expert, then it is important here that the counter function is written correctly and there are no other concerns. When using the OnTick function, I'm not entirely sure whether I can use only the appearance of a new tick or if I have to use timers as well. So far, I have not had such a situation that the tick does not arrive within the desired time, and that is why I cannot comment further for the time being. Logic says that if a tick does not come for too long, then something is very wrong and there is no point in trading anyway. In addition, since no new tick arrives, nothing can change in the calculations unless a deeper data analysis is done - so I don't see a problem at the moment. It probably makes sense to disable the trading functions for the time being if the counter does not change for too long. I measured the results and I don't use the struct in mqlrates myself because I need less data for my larger processing. Maybe if there is more time, we can continue with this, but at the moment I will not dwell on this topic any more. Finally I will also add a very simple code that I myself use now, for those who are on the same path and want to test it themselves.

function: 

template <typename TS>
void fill_ts_arr(TS &arr[],int bars, int &count) 
{
    
    if (ArraySize(c)<bars)
    {
        ArrayResize(h,bars);
        ArrayResize(l,bars);
        ArrayResize(t,bars);
        for (int i = bars-1; i >= 0; i--) {h[i] = iHigh (NULL,0, bars -i);}
        for (int i = bars-1; i >= 0; i--) {l[i] = iLow  (NULL,0, bars -i);} 
        for (int i = bars-1; i >= 0; i--) {t[i] = iTime (NULL,0, bars -i);}
        count = bars;
    }
    else        
    {
        ArrayResize(h, count);
        ArrayResize(l, count);
        ArrayResize(t, count);
        h[count-1] = iHigh (NULL, 0, 1);
        l[count-1] = iLow  (NULL, 0, 1);
        t[count-1] = iTime (NULL, 0, 1);
    }
}

and call:

fill_ts_arr(t,lookback,ts_count);
    fill_ts_arr(h,lookback,ts_count);
    fill_ts_arr(l,lookback,ts_count);
    ts_count++;