Olá pessoal, boa tarde
Estou tentando usar o método copyticks, no entanto estou recebendo um erro 4014 no getlasterror.
Meu código é este:
//+------------------------------------------------------------------+
//| copyticks.mq5 |
//| Copyright 2016, MetaQuotes Software Corp. |
//|
https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
//--- input parameters
input int ticks=10;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
//EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
//EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--- the array that receives ticks
MqlTick tick_array[];
//--- requesting ticks
int copied=CopyTicks(_Symbol,tick_array,COPY_TICKS_ALL,0,ticks);
//--- if ticks are received, show the Bid and Ask values on the chart
if(copied>0)
{
string comment="# Time Bid Ask\r\n";
//--- generate the comment contents
for(int i=0;i<copied;i++)
{
MqlTick tick=tick_array[i];
string tick_string=StringFormat("%d: %s %G %G",
i,
TimeToString(tick.time,TIME_MINUTES|TIME_SECONDS),
tick.bid,
tick.ask);
comment=comment+tick_string+"\r\n";
}
//--- show a comment on the chart
Alert(comment);
}
else // report an error that occurred when receiving ticks
{
Alert("Ticks could not be loaded. GetLastError()=",GetLastError());
}
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
Obrigado
Felipe