怎么计算挂单的多空数量
怎么计算挂单的多空数量 int BuyPendingOrders = 0;int SellPendingOrders = 0;
void CountPendingOrders() {
// 遍历所有挂单
for (int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
// 检查订单是否是挂单
if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT) {
BuyPendingOrders++;
} else if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) {
SellPendingOrders++;
}
}
}
}
void OnStart() {
// 初始化计数
BuyPendingOrders = 0;
SellPendingOrders = 0;
// 计算挂单的多空数量
CountPendingOrders();
// 输出结果
Print("Buy Pending Orders: ", BuyPendingOrders);
Print("Sell Pending Orders: ", SellPendingOrders);
}
元氣美少女 发表于 2024-11-12 15:11
感谢^ω^
页:
[1]