MT4 API Active Orders

easy direct connection to any MT4 and MT5 server

MT4 API Active Orders

Sample how to get the list of opened positions and pending orders.

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");
      foreach (Order order in qc.GetOpenedOrders())
         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