#1
To calculate the total number of Buy and Sell orders in your MT4 account, you can use the OrdersTotal() function in combination with the OrderSelect() function to retrieve information about each order and check whether the order is a Buy or Sell order. For example, to calculate the total number of Buy orders, you can use the following code:

int total_buy_orders = 0;
int total_orders = OrdersTotal();

for (int i = 0; i < total_orders; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
        if (OrderType() == OP_BUY) {
            total_buy_orders++;
        }
    }
}
To calculate the total number of Sell orders, you can use the following code:

int total_sell_orders = 0;
int total_orders = OrdersTotal();

for (int i = 0; i < total_orders; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
        if (OrderType() == OP_SELL) {
            total_sell_orders++;
        }
    }
}
Note that the above code snippets only calculate the total number of orders currently present in your MT4 account. If you want to calculate the total number of orders within a specific time range, you would need to add a condition to check the order open time of each order.

image quote pre code
Xem hướng dẫn đăng nhập để đăng bình luận Tại Đây
Chia sẻ: