Joás Bezerra:
If I put it on April 2018, It will be shown from there until today.
Therefore, it has to use a lot of memory and time to calculate all these data.
for(int i=iRatesTotal-1; i>0; i--) { if(obj_time>=(long)iTime[i]) {startVWAP=i; break;} }
You calculate all bars, not just from when. Calculate only what has changed.
How to do your lookbacks correctly.- You have seven (7) arrays. If you have 5000 bars, that takes 7*5000*8 or 274 KB (on a 4 million KB machine.) What do you mean it "use a lot of memory?" As for time, see #1
- You resize your arrays on the first tick only. Therefor once you exceed 1.5 original bar count you fail with array exceeded. You would know that if you had used strict.
Always use strict. Fixing the warnings will save you hours of debugging.
Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference - Why do you initialize your arrays to zero when the next thing you do is fill them?
- Why are you filling those arrays? On MT5 you can use copyX routines and take no memory (except for the buffer.) On MT4 you don't need them at all, use the predefined arrays, no filling required.
else if(Method==High) else if(Method==Low) else if(Method==Median) else if(Method==Typical) else if(Method==Weighted)
Multiple tests, use switch.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey, guys!
I want to do some backtesting, but the indicator I'm studying gets very heavy and slow.
If I put it on April 2018, It will be shown from there until today. Therefore, it has to use a lot of memory and time to calculate all these data.
How can I limit it so it will be shown day by day?
Here is the code: