Esempio n. 1
0
        public PingInfo GetPingInfo()
        {
            PingInfo ping = _client.Ping();

            return(ping);
        }
Esempio n. 2
0
        /// <summary>
        ///     Ping
        /// </summary>
        public PingInfo Ping()
        {
            string rc = Command(string.Format("PI"));
            if (!ResponseOK(rc) || rc.Length < 3)
                return null;

            string[] reply = rc.Substring(3).Split(new[] {' '});
            if (reply.Length != 28)
                return null;

            try
            {
                string symbol = reply[0];
                var period = (PeriodType) int.Parse(reply[1]);

                DateTime time = FromTimestamp(reply[2]);
                double bid = StringToDouble(reply[3]);
                double ask = StringToDouble(reply[4]);
                int spread = int.Parse(reply[5]);
                double tickvalue = StringToDouble(reply[6]);

                DateTime bartime = FromTimestamp(int.Parse(reply[7]));
                double open = StringToDouble(reply[8]);
                double high = StringToDouble(reply[9]);
                double low = StringToDouble(reply[10]);
                double close = StringToDouble(reply[11]);
                int volume = int.Parse(reply[12]);

                DateTime bartime10 = FromTimestamp(int.Parse(reply[13]));

                double accountBalance = StringToDouble(reply[14]);
                double accountEquity = StringToDouble(reply[15]);
                double accountProfit = StringToDouble(reply[16]);
                double accountFreeMargin = StringToDouble(reply[17]);

                int positionTicket = int.Parse(reply[18]);
                int positionType = int.Parse(reply[19]);
                double positionLots = StringToDouble(reply[20]);
                double positionOpenPrice = StringToDouble(reply[21]);
                DateTime positionOpenTime = FromTimestamp(reply[22]);
                double positionStopLoss = StringToDouble(reply[23]);
                double positionTakeProfit = StringToDouble(reply[24]);
                double positionProfit = StringToDouble(reply[25]);
                string positionComment = reply[26];
                string parameters = reply[27];

                bridge.BarsManager.UpdateBar(symbol, period, bartime, open, high, low, close, volume, bartime10);

                var pingInfo = new PingInfo(symbol, period, bartime, time, bid, ask, spread, tickvalue,
                    accountBalance, accountEquity, accountProfit, accountFreeMargin, positionTicket, positionType,
                    positionLots, positionOpenPrice, positionOpenTime, positionStopLoss, positionTakeProfit,
                    positionProfit, positionComment,
                    parameters);

                return pingInfo;
            }
            catch (FormatException)
            {
                return null;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Ping
        /// </summary>
        public PingInfo Ping()
        {
            string rc = Command(string.Format("PI"));

            if (!ResponseOK(rc) || rc.Length < 3)
            {
                return(null);
            }

            string[] reply = rc.Substring(3).Split(new[] { ' ' });
            if (reply.Length != 28)
            {
                return(null);
            }

            try
            {
                string symbol = reply[0];
                var    period = (PeriodType)int.Parse(reply[1]);

                DateTime time      = FromTimestamp(reply[2]);
                double   bid       = StringToDouble(reply[3]);
                double   ask       = StringToDouble(reply[4]);
                int      spread    = int.Parse(reply[5]);
                double   tickvalue = StringToDouble(reply[6]);

                DateTime bartime = FromTimestamp(int.Parse(reply[7]));
                double   open    = StringToDouble(reply[8]);
                double   high    = StringToDouble(reply[9]);
                double   low     = StringToDouble(reply[10]);
                double   close   = StringToDouble(reply[11]);
                int      volume  = int.Parse(reply[12]);

                DateTime bartime10 = FromTimestamp(int.Parse(reply[13]));

                double accountBalance    = StringToDouble(reply[14]);
                double accountEquity     = StringToDouble(reply[15]);
                double accountProfit     = StringToDouble(reply[16]);
                double accountFreeMargin = StringToDouble(reply[17]);

                int      positionTicket     = int.Parse(reply[18]);
                int      positionType       = int.Parse(reply[19]);
                double   positionLots       = StringToDouble(reply[20]);
                double   positionOpenPrice  = StringToDouble(reply[21]);
                DateTime positionOpenTime   = FromTimestamp(reply[22]);
                double   positionStopLoss   = StringToDouble(reply[23]);
                double   positionTakeProfit = StringToDouble(reply[24]);
                double   positionProfit     = StringToDouble(reply[25]);
                string   positionComment    = reply[26];
                string   parameters         = reply[27];

                bridge.BarsManager.UpdateBar(symbol, period, bartime, open, high, low, close, volume, bartime10);

                var pingInfo = new PingInfo(symbol, period, bartime, time, bid, ask, spread, tickvalue,
                                            accountBalance, accountEquity, accountProfit, accountFreeMargin, positionTicket, positionType,
                                            positionLots, positionOpenPrice, positionOpenTime, positionStopLoss, positionTakeProfit,
                                            positionProfit, positionComment,
                                            parameters);

                return(pingInfo);
            }
            catch (FormatException)
            {
                return(null);
            }
        }