Make a certification service for programmers ... - page 5

 
VOLDEMAR:

I would very much like to know what's wrong with this option ???

You have a sequence of n orders. You have selected an order m(m<n) with the OrderSelect function.

During the processing of order m, the server closes order m-1, and the position of order m (which you are processing) changes to m-1.

In the next loop, you go to process order m-1 and think it is a new order, but no, it is the same order m

Which has changed its position and taken the place of the order closed by the server. So you process two orders in a row

the same order twice in a row.

Документация по MQL5: Торговые функции / OrderSelect
Документация по MQL5: Торговые функции / OrderSelect
  • www.mql5.com
Торговые функции / OrderSelect - Документация по MQL5
 
MrGold166:
it's mql4 ...
I thought we were on forum 5 :)
 

Everything is mixed up in the house...

If MQL6 is introduced and MQL4 isn't gone yet, what will happen then?

 
sandex:

You have a sequence of n orders. You have selected order m(m<n) with OrderSelect.

While you are processing order m, the server closes order m-1 and the position of order m (which you are processing) changes to m-1.

In the next loop, you go to process order m-1 and think it is a new order, but no, it is the same order m

Which has changed its position and taken the place of the order closed by the server. So you process two orders in a row

the same order.

I do not agree ... And may the forum users judge us ....

for(i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{

We have 10 orders in the terminal ... but in the list the orders are 0 1 2 3 4 5 6 7 8 9 Ten ? 0 from programming is difficult to remove.

So OrdersTotal() will have a value of 10, but in reverse counting we take the total of orders as 10-1, i.e. 9, and when we get to 0, we call one more integration of the loop 0>=0

it means we have 1 order left which we go over at this point 0>=0.

Nothing is too natural or wrong ....

 

Ahaa! I get the point of this thread!

It will help identify coders who may be talking nonsense or stupid right in the same thread.

Which means they automatically go by the algorithm: said stupid - ban. :)

So feel free to express your most "intelligent" thoughts. Maybe you'll get lucky ;)

 
sandex:
That's the point of the overshooting from the end, there is nothing military about processing one order twice. In the worst case it only prevents us if we count orders, for example the average price, one order will be counted 2 times. Even if it strongly interferes with the calculations, on the next tick everything will return to its place and we will put the take profit where it should be. In my memory with more than 50 orders and with the worst so-called Asian "broker" (yes, you know who I mean) this has never happened after the account was traded (you know why). But it can also be avoided:

int i,last_ticket;
for(i=OrdersTotal()-1;i>=0;i--) if(OrderSelect(i,SELECT_BY_POS) {
   if(OrderTicket()==last_ticket) continue;
   last_ticket=OrderTicket();
   }
Документация по MQL5: Торговые функции / OrdersTotal
Документация по MQL5: Торговые функции / OrdersTotal
  • www.mql5.com
Торговые функции / OrdersTotal - Документация по MQL5
 
one is better than the other)))
 
snowman:

one is better than the other)))
You can only troll? Offer your version with an explanation ...
 
VOLDEMAR:
You can only troll ??? Offer your version with an explanation ...
What for? For whom? The feeling that here can only argue about how to correctly search for orders and who of all the programmers present here is worthy of working in Job.
 
snowman:
What for? For whom? They are all in the same place, but they do not have any idea how to deal with orders and who of all the programmers present here is worthy of working in Job.
If you have nothing good to say, keep quiet or talk sense, ..... If you knew something, you'd show me... Or sorry? Or don't know anything ....