MT4 API History Orders

easy direct connection to any MT4 and MT5 server

MT4 API History Orders

From and To parameters it’s server time, not local time. Some servers doesn’t interpret From and To time precisely so we recommend to subsctruct several hours from From time and add several hours to To time to get orders from required range with guarantee.

void Run()
{
   try
   {
      MainServer srv = QuoteClient.LoadSrv(@"GerchikCo-Demo.srv");
      QuoteClient qc = new QuoteClient(67611, "wx1yhpn", srv.Host, srv.Port);
      Console.WriteLine("Connecting...");
      qc.Connect();
      Console.WriteLine("Connected to server");
      DateTime from = DateTime.Now.AddDays(-1);
      DateTime to = DateTime.Now;
      foreach (Order order in qc.DownloadOrderHistory(from, to))
         Console.WriteLine(order);
      Console.WriteLine("Press any key...");
      Console.ReadKey();
      qc.Disconnect();
 
 
   }
   catch (Exception ex)
   {
      Console.WriteLine(ex.Message);
      Console.WriteLine("Press any key...");
      Console.ReadKey();
   }
}

 

 

Leave a Reply