I am writing this code in order to read the history of a symbol and save it in a dynamic array, but it returns (copied = -1), which means it cannot read anything. What is wrong with it?
//+------------------------------------------------------------------+ //| aa.mq5 | //| Copyright 2010, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2010, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { MqlRates rates[]; int copied = CopyRates(Symbol() , PERIOD_M1 , D'2007.01.01 00:00:00' , D'2008.01.01 00:00:00' , rates); if(copied>0) { Print("Bars copied: "+copied); string format="open = %G, high = %G, low = %G, close = %G, volume = %d"; string out; int size=fmin(copied,10); for(int i=0;i<size;i++) { out = i + " : " + TimeToString(rates[i].time); out = out + " " + StringFormat(format, rates[i].open, rates[i].high, rates[i].low, rates[i].close, rates[i].tick_volume); Print(out); } } else Print("Failed to get history data for the symbol ",Symbol()); } //+------------------------------------------------------------------+
Probably between these dates too much information for the selected period.
Try to choose another period or change interval of the dates.
I tried on this interval of the dates with a period in 15M.
Probably between these dates too much information for the selected period.
Try to choose another period or change interval of the dates.
I tried on this interval of the dates with a period in 15M.
Since a few days ago I'm having the same problem (previously my code was working fine). I think there is an issue here. I tried the posted code with a 15M period and it doesn't work.
Data is present in the directory Bases\MetaQuotes-Demo\history\ and I am using the same corresponding account.
Any help would be greatly appreciated.

- 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 am writing this code in order to read the history of a symbol and save it in a dynamic array, but it returns (copied = -1), which means it cannot read anything. What is wrong with it?
//+------------------------------------------------------------------+
//| aa.mq5 |
//| Copyright 2010, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
MqlRates rates[];
int copied = CopyRates(Symbol() , PERIOD_M1 , D'2007.01.01 00:00:00' , D'2008.01.01 00:00:00' , rates);
if(copied>0)
{
Print("Bars copied: "+copied);
string format="open = %G, high = %G, low = %G, close = %G, volume = %d";
string out;
int size=fmin(copied,10);
for(int i=0;i<size;i++)
{
out = i + " : " + TimeToString(rates[i].time);
out = out + " " + StringFormat(format,
rates[i].open,
rates[i].high,
rates[i].low,
rates[i].close,
rates[i].tick_volume);
Print(out);
}
}
else Print("Failed to get history data for the symbol ",Symbol());
}
//+------------------------------------------------------------------+