How to get the current totalorders of buy lots and sell lots. Anyone? I need help
in this.
- Need help in this code
- get the lot size
- order count
int TotalBuy() { int count=0; for (int i=0; i<OrdersTotal(); i++) { if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break; if (OrderSymbol()!=Symbol()) continue; if (OrderType()==OP_BUY) count++; } return (count); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- int TotalSell() { int count=0; for (int i=0; i<OrdersTotal(); i++) { if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break; if (OrderSymbol()!=Symbol()) continue; if (OrderType()==OP_SELL) count++; } return (count); }
Thanks, but tht counts the number of buy and sell. I only want the total lots. Im having this code but it doesnt work. It doesnt return the total lots of buy and sell. Anyone? int BuyLots=0; int SellLots=0; int mode; for(cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode=OrderType(); BuyLots=OrderLots(); SellLots=OrderLots(); if (OrderSymbol()==Symbol()) { if (mode==OP_BUY) { BuyLots++; } if (mode==OP_SELL) { SellLots++; } } }
Your lot count is reset to the current trade volume for every new order you count.
Try this:
int BuyLots=0; int SellLots=0; int mode; for(cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode=OrderType(); if (OrderSymbol()==Symbol()) { if (mode==OP_BUY) { BuyLots += OrderLots(); } if (mode==OP_SELL) { SellLots += OrderLots(); } } }
Tht doesnt work either.
Thanks... it works now :)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register