Here's one way to do it:
// Inventory Orders int Buys = 0, Sells = 0, BuyLimits = 0, SellLimits = 0; for(int cnt = OrdersTotal() - 1 ; cnt >= 0 ; cnt-- ) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { if(OrderType() == OP_BUY) { Buys++; } if(OrderType() == OP_SELL) { Sells++; } if(OrderType() == OP_BUYLIMIT) { BuyLimits++; } if(OrderType() == OP_SELLLIMIT) { SellLimits++; } } }
Any other data that you want to pluck out of the order you would have to do inside the first "if" statement. You will have to decide how to keep each order and its associated data together - perhaps an array...
Here's one way to do it:
Any other data that you want to pluck out of the order you would have to do inside the first "if" statement. You will have to decide how to keep each order and its associated data together - perhaps an array...
Dear Tovan,
Great. I think it will help me do what I need.
Since I have all orders "ordered" and specific lot size for each or sent with this code you send I can get the desired results. For instance, if on the variable "Buys" I get a value "3", I know that the lot sizes are 0.1 and 0.2, 0.3.
Thank you very much
Regards
Paulo
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
Can anyone help me to identify via MQL what are the currently running trades?
I know how to find if there is a specific trade running via magic number or by trade type.
What I need is to identify how many trades I have with a specific magic number and a specific type (SELL/BUY).
For instance, I get 3 BUY trades:
MAGIC: XXXXXXXX (the same for all)
Trade number 1: 0,1 lot
Trade number 2: 0,2 lot
Trade number 3: 0,3 lot
How can I get the lot sizes for each trade? And how to identify them?
The requirements I have works exactly by the order shown. First trade 0.1, secoond 0.2 third 0.3... etc.
What I need for instance, is to detect is the second and thirrt orders are already working and perhaps send a 4th order.
Thank you all
Regards
Paulo