private void OnTickRecieved(String symbol, MqlTick tick) { TickRecievedEventArgs e = new TickRecievedEventArgs(symbol, tick); EventHandler <TickRecievedEventArgs> temp = TickRecieved; if (temp != null) { temp(this, e); } }
/// <summary> /// Sends tick to all clients /// </summary> public void SendTick(String symbol, MqlTick tick) { lock (lockClients) for (int i = 0; i < _Clients.Count; i++) { try { _Clients[i].SendTick(symbol, tick); } catch (CommunicationException) { // it seems that connection with client has lost - let's delete him _Clients.RemoveAt(i); i--; } } }
static void Main(string[] args) { ExportService host = new ExportService("mt5"); host.Open(); Console.WriteLine("Press any key to start tick export"); Console.ReadKey(); int total = 0; Stopwatch sw = new Stopwatch(); for (int c = 0; c < 10; c++) { int counter = 0; sw.Reset(); sw.Start(); while (sw.ElapsedMilliseconds < 1000) { for (int i = 0; i < 100; i++) { MqlTick tick = new MqlTick { Time = 640000, Bid = 1.2345 }; host.SendTick("GBPUSD", tick); } counter++; } sw.Stop(); total += counter * 100; Console.WriteLine("{0} ticks per second", counter * 100); } Console.WriteLine("Average {0:F2} ticks per second", total / 10); host.Close(); Console.ReadKey(); }
public static int AddTick(ref MqlTick tick, ref double bidsum) { bidsum = 0.0; if (list == null) { list = new List <MqlTick>(); } tick.Volume = 666; list.Add(tick); foreach (MqlTick t in list) { bidsum += t.Ask; } return(list.Count); }
private void OnTickRecieved(String symbol, MqlTick tick) { TickRecievedEventArgs e = new TickRecievedEventArgs(symbol, tick); EventHandler<TickRecievedEventArgs> temp = TickRecieved; if (temp != null) temp(this, e); }
public void SendTick(string symbol, MqlTick tick) { OnTickRecieved(symbol, tick); }
public TickRecievedEventArgs(String symbol, MqlTick tick) { Symbol = symbol; Tick = tick; }
/// <summary> /// Sends tick to all clients /// </summary> public void SendTick(String symbol, MqlTick tick) { lock (lockClients) for (int i = 0; i < _Clients.Count; i++) try { _Clients[i].SendTick(symbol, tick); } catch (CommunicationException) { // it seems that connection with client has lost - let's delete him _Clients.RemoveAt(i); i--; } }