Hello, is there a more elegant way to limit the number of bars for calculation , for both counting up and counting down ?
i.e
Please suggest, thanks in advance.
//---- main indicator calculation loop for(bar=MathMin(3-bar,rates_total-1-50); bar>=0 && !IsStopped(); bar--) { // no need for if, it starts with the min value
Not quite sure what you are asking for, but only looking technically to your loop, it can be improved.
Thanks for the code snippet, what I'm basiclly trying to achieve is faster execution of an indicator by calculating only the latest 3 bars instead of looping through, say 50,000 bars returned by rates_total,I dont know if that makes sense. I'm calling 13 indicators using Icustom using 26 CopyBuffers, cpu usage is through the roof and so is memory usage.
What MT5 tells me:
What I'm trying to do:
Thanks for the code snippet, what I'm basiclly trying to achieve is faster execution of an indicator by calculating only the latest 3 bars instead of looping through, say 50,000 bars returned by rates_total,I dont know if that makes sense. I'm calling 13 indicator using Icustom using 26 CopyBuffers, cpu usage is through the roof and so is memory usage.
What MT5 tells me:
What I'm trying to do:
Then you need something much simpler like
Thanks alot, I'll try it out and give feedback.
Then you need something much simpler like
Hi, Amir, thanks, this works beautifully for counting up:
bar--
However, for counting down:
bar++
No joy, I tried reversing the values;
for ( bar=0;bar<3;bar++)
Thanks.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, is there a more elegant way to limit the number of bars for calculation , for both counting up and counting down ?
i.e
Please suggest, thanks in advance.