Exemplo n.º 1
0
        private void metaTrader4_QuoteRecieved(QuoteListener mql)
        {
            if (OrderCount != mql.OrdersTotal())
            {
                this.Dispatcher.BeginInvoke((Action)(() => { DataGridOpen.Items.Clear(); }));

                for (int i = mql.OrdersTotal() - 1; i >= 0; i--)
                {
                    if (mql.OrderSelect(i, SELECT_BY.SELECT_BY_POS))
                    {
                        int    orderTicket = mql.OrderTicket();
                        string orderSymbol = mql.OrderSymbol();
                        double orderLots   = mql.OrderLots();
                        double orderProfit = mql.OrderProfit();

                        var data = new DataGridRowAdd {
                            OrderTicket = orderTicket, Symbol = orderSymbol, Size = orderLots, Profit = orderProfit
                        };

                        this.Dispatcher.BeginInvoke((Action)(() => { DataGridOpen.Items.Add(data); }));
                    }
                }
            }

            if (HistoryCount != mql.HistoryTotal())
            {
                this.Dispatcher.BeginInvoke((Action)(() => { DataGridHistory.Items.Clear(); }));

                for (int i = mql.HistoryTotal() - 1; i >= 0; i--)
                {
                    if (mql.OrderSelect(i, SELECT_BY.SELECT_BY_POS, POOL_MODES.MODE_HISTORY))
                    {
                        int    orderTicket = mql.OrderTicket();
                        string orderSymbol = mql.OrderSymbol();
                        double orderLots   = mql.OrderLots();
                        double orderProfit = mql.OrderProfit();

                        var data = new DataGridRowAdd {
                            OrderTicket = orderTicket, Symbol = orderSymbol, Size = orderLots, Profit = orderProfit
                        };

                        this.Dispatcher.BeginInvoke((Action)(() => { DataGridHistory.Items.Add(data); }));
                    }
                }
            }

            HistoryCount = mql.HistoryTotal();
            OrderCount   = mql.OrdersTotal();

            double bid = mql.Bid();
            double ask = mql.Ask();

            this.Dispatcher.BeginInvoke((Action)(() => { BidPrice.Content = "Bid: " + bid.ToString(); }));
            this.Dispatcher.BeginInvoke((Action)(() => { AskPrice.Content = "Ask: " + ask.ToString(); }));
        }
        private void metaTrader4_QuoteRecieved(QuoteListener mql)
        {
            if (OrderCount != mql.OrdersTotal())
            {
                this.Dispatcher.BeginInvoke((Action)(() => { DataGridOpen.Items.Clear(); }));
                
                for (int i = mql.OrdersTotal() - 1; i >= 0; i--)
                {
                    if (mql.OrderSelect(i, SELECT_BY.SELECT_BY_POS))
                    {
                        int orderTicket = mql.OrderTicket();
                        string orderSymbol = mql.OrderSymbol();
                        double orderLots = mql.OrderLots();
                        double orderProfit = mql.OrderProfit();

                        var data = new DataGridRowAdd { OrderTicket = orderTicket, Symbol = orderSymbol, Size = orderLots, Profit = orderProfit};

                        this.Dispatcher.BeginInvoke((Action)(() => { DataGridOpen.Items.Add(data); }));
                    }
                }
            }

            if (HistoryCount != mql.HistoryTotal())
            {
                this.Dispatcher.BeginInvoke((Action)(() => { DataGridHistory.Items.Clear(); }));

                for (int i = mql.HistoryTotal() - 1; i >= 0; i--)
                {
                    if (mql.OrderSelect(i, SELECT_BY.SELECT_BY_POS, POOL_MODES.MODE_HISTORY))
                    {
                        int orderTicket = mql.OrderTicket();
                        string orderSymbol = mql.OrderSymbol();
                        double orderLots = mql.OrderLots();
                        double orderProfit = mql.OrderProfit();

                        var data = new DataGridRowAdd { OrderTicket = orderTicket, Symbol = orderSymbol, Size = orderLots, Profit = orderProfit};

                        this.Dispatcher.BeginInvoke((Action)(() => { DataGridHistory.Items.Add(data); }));
                    }
                }
            }

            HistoryCount = mql.HistoryTotal();
            OrderCount = mql.OrdersTotal();

            double bid = mql.Bid();
            double ask = mql.Ask();

            this.Dispatcher.BeginInvoke((Action)(() => { BidPrice.Content = "Bid: " + bid.ToString(); }));
            this.Dispatcher.BeginInvoke((Action)(() => { AskPrice.Content = "Ask: " + ask.ToString(); }));
        }
Exemplo n.º 3
0
        private void OrderClose_Click(object sender, RoutedEventArgs e)
        {
            DataGridRowAdd value = (DataGridRowAdd)DataGridOpen.SelectedItem;

            metaTrader4.MqlScope(mql =>
            {
                mql.OrderSelect(value.OrderTicket, SELECT_BY.SELECT_BY_TICKET);
                if (mql.OrderType() == ORDER_TYPE.OP_BUY)
                {
                    mql.OrderClose(value.OrderTicket, mql.OrderLots(), mql.Bid(), 3);
                }
                else
                {
                    mql.OrderClose(value.OrderTicket, mql.OrderLots(), mql.Ask(), 3);
                }
            });
        }