Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
The "slowness" of your indicator, is probably because of "poor" or incorrect implementation.
If you need help with your code, it is best that you show your code, or at least a sample of your code that can reproduce the issue.
Hi everyone,
I made myself an indicator which, however, needs a lot of time(too much?) for calculation. I like to use it on lower timeframes with many(can be ~1000) intervals to calculate. Indicator values, once calculated in history(index values 1 and higher in time series) do not change and indicator values on present time interval(index =0) do change according to latest interval high-low values.
My question is: when/what triggers program calculation in general? Does calculation happen only on latest interval when there is new tick(?) or on all intervals visible even if they have already been calculated before?
Is there some approach for time series calculation that is quicker than using arrays[], for and if sentences?
Also: sometimes it happens that to me that indicator value changes slightly after moving from completed latest interval(index=0) to penultimate(index=1). Can this be because last(=current) interval values are from my broker and history values are from Metatrader history server? Or?
Regards,
hi
i assume you are not looping through all the bars each time.
when prev_calculated is 0 it indicates that the series has changed more than just one bar (so its signaling that new data loaded in the past or spliced in).This is regarding your offsets in display .In these cases the terminal will not autoshift the buffers correctly (nor should it)
To handle the load , set a load limit or load batches .When the user scrolls back till the bar you have loaded offer an on chart "load more" button.If your calculations are heavy - and not slow due to mistakes in code - then this is the best approach.
Cons :
if you have a load limiter and the terminal keeps loading new bars in the past in intervals,then it triggers the prev_calculated=0 constantly which will make your indicator recalculate again.
if you decide to skip that recalculation then you will have to shift the index buffers yourself and place them in the correct time range.
My question is: when/what triggers program calculation in general? Does calculation happen only on latest interval when there is new tick(?) or on all intervals visible even if they have already been calculated before?
both, but answering this question won't help you I'm sure. Ticks are calculated, and bars are calculated as well such that historical bars (before prev_calculated - 1) can be ignored in further processing

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I made myself an indicator which, however, needs a lot of time(too much?) for calculation. I like to use it on lower timeframes with many(can be ~1000) intervals to calculate. Indicator values, once calculated in history(index values 1 and higher in time series) do not change and indicator values on present time interval(index =0) do change according to latest interval high-low values.
My question is: when/what triggers program calculation in general? Does calculation happen only on latest interval when there is new tick(?) or on all intervals visible even if they have already been calculated before?
Is there some approach for time series calculation that is quicker than using arrays[], for and if sentences?
Also: sometimes it happens that to me that indicator value changes slightly after moving from completed latest interval(index=0) to penultimate(index=1). Can this be because last(=current) interval values are from my broker and history values are from Metatrader history server? Or?
Regards,