MT5 Market order open/close

easy direct connection to any MT4 and MT5 server

MT5 Market order open/close

Sample below shows how to open and close market order with MT5 API.

var api = new MT5API("45.76.194.231:443", 7371, "mt5api"); 
api.OnConnectStatus += ConnectionStatus;
api.Connect();
string symbol = "EURUSD";
api.Subscribe(symbol);
while (api.GetQuote(symbol) == null)
    Thread.Sleep(1);
var quote = api.GetQuote(symbol);
var o = api.OrderSend(symbol, 100, quote.Ask, OrderType.Buy, 0, 0, 0, null, 0);
Console.WriteLine(o.Ticket);
api.OrderClose(o.Ticket, o.Symbol, quote.Bid, o.Volume, o.OrderType);
Console.WriteLine("Closed");
Console.ReadKey();

Leave a Reply