Download MetaTrader 5
To add comments, please log in or register
Millions of traders download codes from MQL5 library. Share your app with them!
Daniel Jurnik
142
Daniel Jurnik 2014.12.02 17:36 

Hi guys, I have indicator with CopyRates function in OnInit. Something like that:

 

int OnInit() {

  MqlRates pairs[];

   int count = 0;

   

   ArraySetAsSeries(pairs, true);

   

   if (CopyRates(symbol, 0, 0, Bars, pairs) == -1 || ArraySize(pairs) < Bars) {

      Print ("Error: ", GetLastError(), " pairs count: ", ArraySize(pairs), " needed: ", Bars, " ", symbol);

      return -1;

   }

}

If I'm not wrong, then historical data should start downloading but it's not happen. I need exactly same number of indexes in pairs like I have in Bars. However terminal throws this in cycle:

Error: 0 pairs count: 11063 needed: 12212 AUDUSD

I will be thankful of any ideas!
Halley
198
Halley 2014.12.02 17:52  
My idea is trying to replace the Bars by iBars(symbol, 0).
Michal Jurnik
24
Michal Jurnik 2014.12.02 18:10  
DeepThought:
My idea is trying to replace the Bars by iBars(symbol, 0).
It's obviously he wants Bars from actual chart. It will be iBars(Symbol(), 0) but it's same story... maybe something with start datetime.
Halley
198
Halley 2014.12.02 18:56  
Just_Mike:
It's obviously he wants Bars from actual chart. It will be iBars(Symbol(), 0) but it's same story... maybe something with start datetime.

 

Then he probably hit the history limit. He must pick the lesser number of bars for both the symbol and Symbol(). But not sure if it has sense, the candles may not align.

Carl Schreiber
5930
Carl Schreiber 2014.12.02 21:19  
Well I think he hasn't resized his array pairs. So he set an array with size = 0 as ..Series -  can't work :(
Halley
198
Halley 2014.12.03 08:37  
gooly:
Well I think he hasn't resized his array pairs. So he set an array with size = 0 as ..Series -  can't work :(
No, his problem is that he expects the CopyRates downloads data to the index he specified. But there are probably no more data at broker, 11k seems quite usual number for many of them, and many have even less.
/
To add comments, please log in or register