MT4 API Bar History
Getting quote history from server. It's not a tick history, just fimeframe history.
void Run() { try { MainServer srv = QuoteClient.LoadSrv(@"GerchikCo-Demo.srv"); QuoteClient qc = new QuoteClient(67611, "wx1yhpn", srv.Host, srv.Port); qc.OnQuoteHistory += new QuoteHistoryEventHandler(qc_OnQuoteHistory); Console.WriteLine("Connecting..."); qc.Connect(); Console.WriteLine("Connected to server"); qc.Subscribe("EURUSD"); // ServerTime update goes with quotes, wait for first quote while (qc.ServerTime == new DateTime()) Thread.Sleep(10); //request 10 previuos bars Timeframe tf = Timeframe.M5; qc.DownloadQuoteHistory("EURUSD", tf, qc.ServerTime.AddMinutes(-10 * (int)tf), 0); Console.WriteLine("Press any key..."); Console.ReadKey(); qc.Disconnect(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } void qc_OnQuoteHistory(object sender, QuoteHistoryEventArgs args) { if (args.Bars.Length == 1 && args.Bars[0].Time == new DateTime(1970, 1, 1)) return; //null message means that it's the last message foreach (Bar bar in args.Bars) Console.WriteLine(bar); }