Ok, I think I figured it out myself. But I'm not sure if I'm fetching the data OK and free of mistakes. I just added this code lines bellow every iFunction i had on my script:
bananaValues[i] = iClose("BANANA", PERIOD_H1, i); //think i as an iteration variable errorCode = GetLastError(); while (errorCode == 4073 || errorCode == 4066) { Sleep(300); bananaValues[i] = iClose("BANANA", PERIOD_H1, i); errorCode = GetLastError(); }
Please comment if it's right, so other people can use this code too.
Thanks.
Oliver Mohr Bonometti: Please comment if it's right,
|
|
|
- But I can't know if I had an error or not. Didn't understand that point.
- Hardcoded "BANANA" for example, in my code it's a variable. The algorithm iterates over every symbol.
- The whole algorithm that's applied for any symbol needs a picture of the data and that data can't change over the execution time. It's really not that important if it's even 2 minutes lagged.
- What do you mean by test? Then you said "Unless the chart is that specific pair/TF, you must handle 4066/4073 errors", but I'm not using the charts. Didn't understand this point either.

- docs.mql4.com
Oliver Mohr Bonometti:
|
|
|
1. Thanks for the tip. I've been using GetLastError() and I've seen that it's value differs from _LastError value. Why would that be?
4. Why do you say that? I recieve the data from all symbols in my script with all the Charts closed. Am I missing a concept here?
5. I previous said "I'm trying to run an algorithm over every symbol available. The problem is that if I want to get data with iClose for USDCAD for example (...)". I mean to iterate this algorithm over every available symbol in one run of the script.
1. Thanks for the tip. I've been using GetLastError() and I've seen that it's value differs from _LastError value. Why would that be?
4. Why do you say that? I recieve the data from all symbols in my script with all the Charts closed. Am I missing a concept here?
5. I previous said "I'm trying to run an algorithm over every symbol available. The problem is that if I want to get data with iClose for USDCAD for example (...)". I mean to iterate this algorithm over every available symbol in one run of the script.
4. You are missing the fact that any indicator, script, or EA must run on a chart. You can't run anything with all charts closed. Requesting data for other pairs/TF comes from other charts. If they are not currently open, they are opened (hidden,) then updated, they exist (for ten minutes after last access.)
5. You have repeated said that. So what? I gave you a link to my code with an example on how to wait for the other charts to update. Use it.
1. Impossible. Absolutely no difference. Perhaps you should read the manual.
4. You are missing the fact that any indicator, script, or EA must run on a chart. You can't run anything with all charts closed. Requesting data for other pairs/TF comes from other charts. If they are not currently open, they are opened (hidden,) then updated, they exist (for ten minutes after last access.)
5. You have repeated said that. So what? I gave you a link to my code with an example on how to wait for the other charts to update. Use it.
4. I wasn't aware of that... I use copyrates instead with the exception of iBarshift and I have never had to open a chart. Would it be safe to say copyrates is exempt from those rules?
Thanks for commenting nicholishen. I think CopyRates is what I need in my script. If you know anything about your question "Would it be safe to say copyrates is exempt from those rules?" please comment it on the thread.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm trying to run an algorithm over every symbol available. The problem is that if I want to get data with iClose for USDCAD for example, I need to have that chart open, otherwise I'll get 0 because local history hasn't been loaded. So far, I've been trying to Open and Close the symbol's chart programmatically to get that historic data loaded.
I'd like to know how to load that data (and getting rid of it so I don't run out of RAM) without having to open and close charts, so I can use those iClose and iTime functions.
Thanks.