Hi,
Is there a function returning ONLY the market orders count, Please
TIA
Best regards
BBF
Thanks for trying to help... but this function return market orders count AND pending orders count.
I'm interested for a function that returns the market orders count ONLY.
Best regards
BBF
Hi,
No there is no such function. You have to make a loop counting the orders you want to count, according to the TYPE to select wether it is a pending order or not.
I give you an idea of what I mean:
int MarketOrderCount() {int answer = 0; int curOrder, numOrders = OrdersTotal(); for(curOrder = 0; curOrder < numOrders; curOrder++) {// GET ORDER if (!GetOrderByPos(curOrder)) return(9999); // GET ORDER OK if (OrderType() != OP_BUY && OrderType() != OP_SELL) // no pending orders will be treated //(or test with other OP_ options depending on your //treatments) continue; // jump to the next element in the loop answer++; } return(answer) } Check this out, I just wrote it like that not even compiled it.
Thanks for trying to help... but this function return market orders count AND pending orders count.
I'm interested for a function that returns the market orders count ONLY.
Best regards
BBF
Ok, here you are:
int c = 0; int total = OrdersTotal(); for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderType()==OP_BUY || OrderType()==OP_SELL) { c++; } }Cheers
BBF
Something like this...
int OpenTradesForMNForType(int iMN, int iType) { // Call as example // if(OpenTradesForMNForType(MagicNumber, OP_BUY) < 2).... int icnt, itotal, retval; retval=0; itotal=OrdersTotal(); for(icnt=0;icnt<itotal;icnt++) { OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES); // check for opened position & MagicNumber if((OrderType()==iType) && (OrderMagicNumber()==iMN)) { retval++; } } return(retval); }
Good Luck
-BB-
- 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,
Is there a function returning ONLY the market orders count, Please
TIA
Best regards
BBF