public void Close()
        {
            TrenderOrderManager orderManager = new TrenderOrderManager(_mqlApi, _symbol);

            // Get list of orders
            List<Order> orders = orderManager.GetOrders(_symbol);

            // Close each order
            foreach (var order in orders)
            {
                CloseOrderRequest closeOrderRequest = new CloseOrderRequest
                {
                    Magic = 1000000,
                    Slippage = 3
                };
                orderManager.CloseAllOrders(closeOrderRequest);
            }
        }
        public CloseOrderResponse CloseAllOrders(CloseOrderRequest request)
        {
            try
            {
                int orderCount = _mqlApi.OrdersTotal();
                for (int i = orderCount - 1; i >= 0; i--)
                {
                    if (!_mqlApi.OrderSelect(i, MqlApi.SELECT_BY_POS, MqlApi.MODE_TRADES))
                        continue;
                    if (_mqlApi.OrderSymbol() != _symbol)
                        continue;
                    if (_mqlApi.OrderMagicNumber() != request.Magic)
                        continue;

                    int type = _mqlApi.OrderType();

                    // Close buys
                    if (type == 0)
                    {
                        _mqlApi.RefreshRates();
                        CloseOrder(_mqlApi.OrderTicket(), _mqlApi.OrderLots(), _mqlApi.MarketInfo(_symbol, MqlApi.MODE_ASK), request.Slippage);
                        continue;
                    }

                    // Close sells
                    if (type == 2)
                    {
                        _mqlApi.RefreshRates();
                        CloseOrder(_mqlApi.OrderTicket(), _mqlApi.OrderLots(), _mqlApi.MarketInfo(_symbol, MqlApi.MODE_BID), request.Slippage);
                        continue;
                    }
                }

                return new CloseOrderResponse();
            }
            catch (Exception exception)
            {
                // Log exception
                throw;
            }
        }