# Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 701

For the first time I tried to write a position opening in the loop, as I don't rule out opening on other pairs as well.

But for some reason nothing opens in the loop! Do I really need a special loop to open them! True, I only checked it in the tester!

I wrote a normal one:

```    optal = OrdersTotal();
for(op = optal-1; op >= 0; op--)
{
{
if(OrderSymbol() != Symbol()) continue;
if(OrderMagicNumber() != magic) continue;
// и т.д.```

What is wrong for opening orders, positions? Thanks for the help!

For the first time I tried to write a position opening in the loop, as I don't rule out opening on other pairs as well.

But for some reason nothing opens in the loop! Do I really need a special loop to open them! True, I only checked it in the tester!

I wrote a normal one:

What is wrong for opening orders, positions? Thanks for the help!

There until there are no orders the cycle won't start. What is the point of the cycle in general?

For the first time I tried to write a position opening in the loop, as I don't rule out opening on other pairs as well.

But for some reason nothing opens in the loop! Do I really need a special loop to open them!

I wrote a normal one:

What is wrong for opening orders, positions? Thanks for the help!

valeryk:

The loop will not start until there are no orders! What is the purpose of the loop?

Thank you! That's what I thought! So, if, for example, I want to open on the first pair, it is enough without a loop, but with if(OrdersTotal == 0). And when I want to open another order of the same or another pair, I need a loop, and it will work! I will try it now!

I guess I will have to change a lot of things in the opening, but in principle I understand how I should do it! Thank you!

Some pernicious logic, actually. I didn't look carefully at first.... Why do we need OrdersTotal() when opening orders?

Well, if we need to open several orders in the loop, the loop must be organized according to the number of necessary orders. And if we need to constantly support this number, we have to use other rules.

For example, we need to open 7 orders.

```for(int i = 0; i < 7; i++)
{
while(!IsTradeContextBusy()) Sleep(100); // Ожидание освобождения торгового потока

int ticket = OrderSend(Symbol(), ..............); // Открытие ордера
if(ticket > 0) Print("Открылся ордер № ", i, " ticket - ", ticket); // Проверка пропусков при открытии.
}```
But this is a short variant. A good idea would be to add error handling when opening orders

AlexeyVik:

Some pernicious logic, actually. I didn't look carefully at first.... Why do we need OrdersTotal() when opening orders?

Well, if we need to open several orders in the loop, the loop must be organized according to the number of necessary orders. And if we need to constantly support this number, we have to use other rules.

For example, we need to open 7 orders

But this is a short variant. A good idea would be to add error handling when opening orders
!

Thank you! But I need a loop so that owls do not see other pairs! I will deal with errors later! I was even happy when error 130 appeared in the log, it means it works! Errors are handled in my external functions! Thanks again!

Thank you! But I need a loop so owls don't see other pairs! I'll deal with the errors later! I was even happy when error 130 appeared in the log, so it's working! Errors are handled in my external functions! Thanks again!
That's the perniciousness of logic. Owl can't not see other pairs. It can and should be forced not to process other symbols' ORDERS that are already OPEN. In the OrderSend(............) function, you should write a certain Symbol() or in a text format, for example "EURUSD"... whatever you put there will be opened. Or you may try to open it...

AlexeyVik:

Some pernicious logic, actually. I didn't look carefully at first.... Why do we need OrdersTotal() when opening orders?

Well, if we need to open several orders in the loop, the loop must be organized according to the number of necessary orders. And if we need to constantly support this number, we have to use other rules.

For example, we need to open 7 orders

But this is a short variant. A good idea would be to add error handling when opening orders

This is a good way to check if we can open up to eight orders in one tick. We were promised them, but no one has checked them yet

Vinin:

A good way to test the ability to open up to eight orders in a single tick. We were promised them, but no one has checked them yet

I don't get it...

AlexeyVik:

I don't get it...
It is now almost impossible to get the trade flow busy. The number of threads has increased. That's what Vitya said, opening a handful of orders on one tick in the loop would be a good test of the promise made by Metaquotes.