Anyone has some insight as to why these lines don't return rates?
string sym="GBPUSD"; datetime checkt=D'2014.09.22 04:00:00'; MqlRates rates[2]; int cpy=CopyRates(sym,PERIOD_M1,checkt,2,rates);
also trying to bypass this by
int barshiftm1=iBarShift(sym,PERIOD_M1,checkt); int cpy=CopyRates(sym,PERIOD_M1,barshiftm1,2,rates);
gives rates of a different time - hope it relates to same issue
amir_avatar: Anyone has some insight as to why these lines don't return rates? | Don't give it a size. The function doesn't copy to rates, it redirects accesses to rates to mt4's internal buffer. |
Appreciate your intent, even though you haven't tried your suggestion.
Otherwise you would have seen it's not working either (and it can work with rates[2] no problem there, I tried both ways before I posted and [2] works for CopyClose and all other Copy..).
As finally I was able to get response from service desk, this issue is known and should be resolved on next build.
I reported the issue fast a year ago. The service desk answer was like that - do not use time in the parameter, use the bar index which works well.
But this is not the only problem with CopyRates. I sometimes got "access violation error". So finally I am not using this function, but rather ArrayCopyRates and ArrayCopy combo.
Client Terminal Build and Version (32 or 64 bit)
32 build 701
Problem description
CopyRates simple 2nd variation (by datetime,count) does not work
Sequence of action
Just a simple CopyRates
string sym="GBPUSD";
datetime checkt=D'2014.09.22 04:00:00';
MqlRates rates[2];
int cpy=CopyRates(sym,PERIOD_M1,checkt,2,rates);
result - cpy=-1 last error = 4029
when I use same CopyClose or CopyTime with this variation (time,count) it's ok.
Obtained result
error 4029 - array invalid
Expected result
copied 2
Additional details
...
I reported the issue fast a year ago. The service desk answer was like that - do not use time in the parameter, use the bar index which works well.
But this is not the only problem with CopyRates. I sometimes got "access violation error". So finally I am not using this function, but rather ArrayCopyRates and ArrayCopy combo.
I just go to the M1 chart and scroll it backwards. Isn't there an automatic way to download M1 from within MQL4?
I don't mean using TickStory and all that.. I know there isn't and the rates are represented different than the MT5 but it's is just a huge drawback in MT4 making me think of go back to MT5 (which for me has a huge drawback in it's position management system.. )
Metatrader 5 last buid.
My custom indicator in OnCalculate function access rates from higher time frame.
It works good for symbols with long history, but for futures series with short history CopyRates returns 0;
In the same time iBarShift( _Symbol, BIGGER_TIMEFRAME, time[shift] ) returns -1;
This must be some kind od fundamental error of Metatrader 5

- www.mql5.com
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4
The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero on the first call.
On MT5: Unless the chart is that specific
pair/TF, you must Synchronize the terminal Data from the Server.
Is
it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum
Timeseries
and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize
Server Data with Terminal Data - Symbols - General - MQL5 programming forum
SymbolInfoInteger
doesn't work - Symbols - General - MQL5 programming forum 2019.09.03
You're a precious gem, William.
Thank you for this helpful list! :)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Client Terminal Build and Version (32 or 64 bit)
32 build 701
Problem description
CopyRates simple 2nd variation (by datetime,count) does not work
Sequence of action
Just a simple CopyRates
string sym="GBPUSD";
datetime checkt=D'2014.09.22 04:00:00';
MqlRates rates[2];
int cpy=CopyRates(sym,PERIOD_M1,checkt,2,rates);
result - cpy=-1 last error = 4029
when I use same CopyClose or CopyTime with this variation (time,count) it's ok.
Obtained result
error 4029 - array invalid
Expected result
copied 2
Additional details
...