Help - need help debugging my function to count total lots bought (total lots in long position)
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); }
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();