# OrdersTotal() function in Strategy Tester

10

Good evening.

In my first EA I used the OrdersTotal() function to check whether there are open orders or not:

{

[code to open 1 order]

}

But when testing it I found out that after the first order is closed OrdersTotal() still returns 1 and no more orders are sent, as you can see in the attached pics.

It looks like I solved the problem substituing the original OrdersTotal() function with this one:

int OpenOrdersNumber()
{
int number = 0;
for(int i = 0; i<OrdersTotal();i++)
{
if(OrderCloseTime() == 0) number++;
}

return(number);
}

But is it right OrdersTotal() counts also closed orders?

201

michelesmiderle wrote >>

Good evening.

In my first EA I used the OrdersTotal() function to check whether there are open orders or not:

{

[code to open 1 order]

}

But when testing it I found out that after the first order is closed OrdersTotal() still returns 1 and no more orders are sent, as you can see in the attached pics.

It looks like I solved the problem substituing the original OrdersTotal() function with this one:

int OpenOrdersNumber()
{
int number = 0;
for(int i = 0; i<OrdersTotal();i++)
{
if(OrderCloseTime() == 0) number++;
}

return(number);
}

But is it right OrdersTotal() counts also closed orders?

your solution also include OrdersTotal() !

But is it right OrdersTotal() counts also closed orders?

No. Returns market and pending orders count.

It's OrderHistoryTotal().

10

Matutin:

your solution also include OrdersTotal() !

But is it right OrdersTotal() counts also closed orders?

No. Returns market and pending orders count.

It's OrderHistoryTotal().

Includes OrdersTotal(), but I also check that close time is different from 0. Otherwise, as you can see in the pictures, OrdersTotal() returns 1 even when there are no open orders.

So, if as i thought it is not right that OrdersTotal() counts closed orders, what problem is it? And how can I solve it?

Note that when used live, OrdersTotal() works fine: it returns ONLY the number of open orders. It's only in Strategy Tester that I get this problem.

17944

Are you returning from start?
10

WHRoeder:
Are you returning from start?

Yes. The start() function is called and stopped correctly: in fact, the first order is opened.

Data analysis is also carried on correctly (in a test I printed iStochastic values to check).