Organising the order cycle - page 6

 
Alexey Viktorov:

put a check on changing the order list

This way the re-indexing will not be accounted for.

It is clear that if they have been added, they or others will be missed. But what if they were just deleted? We won't be able to leave the order list?

So, there is nothing wrong with it - we will get an error during OrderSelect.

 
fxsaber:

This way the re-indexing will not be taken into account.

That's OK - we'll get an error on OrderSelect.

1. What does indexing/reindexing mean? In my opinion, and flag it in the ... hands, because we'll start a new cycle. Or can you imagine the situation to be even more complicated? Can you imagine that it is possible to open one order and close another at the same time?

2. I agree. I'm not quite awake this morning... I'm not quite awake...

 
Alexey Viktorov:

1. What is meant by indexing/re-indexing? In my opinion and flag in her ... hands, because we're starting a new cycle. Or can you imagine the situation to be even more complicated? Can you imagine that it is possible that one order will be opened and another one closed at the same time?

Yes, this could be one of the scenarios. There is one more variant

some pending order is executed during the cycle

 
fxsaber:

What if during any cycle of working with orders, at each turn, we check if OrdersTotal() and OrdersHistoryTotal() have been changed?

And analyze these values depending on the situation?

 
fxsaber:

Yes, one option could be this. There's also

Some kind of pendulum is fulfilled during the cycle


1. This variant is on the verge of fiction. Well, in the end nothing will happen if it all goes back to normal on the next tick.

2. As I understand it, pending orders must be moved according to the algorithm and the stop will be moved to market orders. Consequently, the order type is checked and executed regardless of the time of execution.

 
Alexey Kozitsyn:

What if during any cycle of working with orders, at each turn, we check if OrdersTotal() and OrdersHistoryTotal() have been changed?

And analyze the obtained values depending on the situation?

Here is a similar suggestion


Forum on trading, automated trading systems and strategy testing

Peculiarities of mql4, tips and tricks

Alexey Viktorov, 2017.09.15 07:24

Firstly, the situation is presented non-standard and few people have already solved this situation, if there are any at all.

Purely theoretically:

For OrderModify it is not necessary to organize reverse loop, so let it be direct.

int i, total = OrdersTotal();
for(i = 0; i < total; i++)

And then we should check for changes in the list of orders

if(total != OrdersTotal())
 {
  i = 0;
  total = OrdersTotal();
  continue;
 }

If the amount of orders has changed, let us start this loop anew with a new amount of orders.

There is also a question:

It is clear that if orders were added, they or others will be skipped. But what if they were simply deleted? We will not go beyond the order list?


only without checking OrdersHistoryTotal()
 
Alexey Viktorov:

Here was a similar suggestion



only without checking OrdersHistoryTotal()
Yes, I read it, just made a point to also check history orders, for the case where simultaneous opening+closing occurred.
 
Alexey Kozitsyn:

What if during any cycle of working with orders, at each turn, we check if OrdersTotal() and OrdersHistoryTotal() have been changed?

And analyze these values depending on the situation?

It may not exist during re-indexing.
 
Alexey Viktorov:

1. this option is on the verge of being a fantasy. Well, in the end, nothing will happen if everything falls into place on the next tick.

The next tick has become a gap. Why put off until tomorrow what can be done today?

2. As I understand it, according to the algorithm, the pending orders should be moved and the stop should be moved to market orders. Therefore, the order type is checked and executed regardless of the time of its execution.

Well, the order type cannot help in any way.

 
fxsaber:
It may not be there when reindexing.

Then maybe we should try to select orders as quickly as possible (just select them!) and write them into an array, and then, in a separate function, check the availability of those orders + the necessary action (close/delete/modify)?

Although I don't think this branch is the best place to discuss it. This branch is for features.