You was so close
double BuyLotsCount() { int lcnt; double SCount; int ltotal = OrdersTotal(); for(lcnt=ltotal-1; lcnt >= 0; lcnt--) { OrderSelect(lcnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_BUY && OrderSymbol()==Symbol()) SCount = SCount + OrderLots(); } return(SCount); }
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
Help - need help debugging my function to count total lots bought (total lots in long position)
I need to know how many lots in long position I had opened.
//-------------------------------
void BuyLotsCount()
{
int lcnt;
int ltotal = OrdersTotal();
for(lcnt=ltotal-1; lcnt >= 0; lcnt--)
{
OrderSelect(lcnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
{
if (OrderLots()>0)
{
int SCount = OrderLots();
SCount = SCount + OrderLots();
return(SCount);
}
}
}
}
//--------------------------------------------------
When I try to use the function, error message - function return no result
SLots = BuyLotsCount();