Beispiel #1
0
        void Api_OnQuote(MT5API api, Quote args)
        {
            try
            {
                Balance = (decimal)api.Account.Balance;
            }
            catch { }

            TickEventArgs tick = null;

            lock (symbolToTick)
            {
                if (symbolToTick.ContainsKey(args.Symbol))
                {
                    tick = symbolToTick[args.Symbol];
                }
            }

            if (tick != null)
            {
                tick.Bid        = (decimal)args.Bid;
                tick.Ask        = (decimal)args.Ask;
                tick.BrokerTime = args.Time;
                CurrentTime     = args.Time;
                Tick?.Invoke(this, tick);
            }
        }
Beispiel #2
0
 public void Subscribe(string symbol)
 {
     lock (symbolToTick)
     {
         try
         {
             if (client.api != null)
             {
                 if (!symbolToTick.ContainsKey(symbol))
                 {
                     TickEventArgs tick = new TickEventArgs();
                     tick.Symbol          = symbol;
                     symbolToTick[symbol] = tick;
                     client.api.Subscribe(symbol);
                 }
             }
         }
         catch (Exception e)
         {
             logger.LogError(ViewId + " " + e.Message);
         }
     }
 }