MT5 order send async

easy direct connection to any MT4 and MT5 server

MT5 order send async

Trading functionality disabled in trial version.

using mtapi.mt5;
using mtapi.mt5.wrapper;
using System;
using System.Threading;
 
namespace TestTrade
{
 
    class Program
    {
        static void Main(string[] args)
        {
            var api = new MT5Client("209.222.26.5:443", 7371, "mt5api");
            api.OnConnectionStatus += ConnectionStatus;
            api.Connect();
            string symnol = "EURUSD";
            api.Subscribe(symnol);
            while (api.GetQuote(symnol).Ask == 0)
                Thread.Sleep(1);
            var quote = api.GetQuote(symnol);
            api.OnTradeResult += Api_OnTradeResult;
            api.OrderSendAsync("EURUSD", 10000, quote.Ask, OrderType.Buy);
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
 
        private static void Api_OnTradeResult(object sender, TradeResult e)
        {
            Console.WriteLine(e.Status);
        }
 
        private static void ConnectionStatus(object sender, ServerStatus e)
        {
            Console.WriteLine(e);
        }
 
    }
}

Leave a Reply