Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1717

 
EVGENII SHELIPOV #:
//--- global parameters
int prev_ticket;
//---
 if(CountTrade() < MaxOrders)
     {
      price = FindLastOrderInfo(2);
      lastlot = NormalizeDouble(GetMinLotOrder()*MathPow(MultiplierParameter, CountTrade()), 2);
      if(FindLastOrderInfo(1) == 0)
        {
         if(Ask<= price - Step()*Point)
           {
            prev_ticket=GetTicketMaxOrder();
            if(OrderSend(Symbol(), OP_BUY, lastlot, Ask, slip, 0, 0, "Групповой ордер на покупку", Magic, 0, Blue))
               Print("Ордер на покупку открыт!");
            else
               Print("Ошибка открытия ордера на покупку! - ",GetLastError());
           }
        }
      if(FindLastOrderInfo(1) == 1)
        {
         if(Bid>= price + Step()*Point)
           {
            prev_ticket=GetTicketMaxOrder();
            if(OrderSend(Symbol(), OP_SELL, lastlot, Bid, slip, 0, 0, "Групповой ордер на продажу", Magic, 0, Red))
               Print("Ордер на продажу открыт!");
            else
               Print("Ошибка открытия ордера на продажу! - ",GetLastError());
           }
        }
     }

before opening an order, store the current max_ticket in prev_ticket

 
MakarFX #:

before opening an order, store the current max_ticket in prev_ticket

MakarFX #:

before opening an order, store the current max_ticket in the prev_ticket

Thank you dear!!!!!

 
MakarFX #:

before opening an order, you store the current max_ticket in the prev_ticket

Makar, the last order may not have a bigger ticket. If a pending order is opened, then a market order, and then a pending order is activated, the ticket of the last order will be smaller than the previous one. Or, if several pending orders are opened, the order sequence will be the same as the order activation sequence, and the tickers will be different.

The opening time is always sequential...

 
And that, people say, is not guaranteed
 
Alexey Viktorov #:

Makar, the last order may not have a bigger ticker. If a pending order is open, then a market order, and then a pending order is activated, then the ticket of the last one will be smaller than the previous one. Or, if several pending orders are opened, the order sequence will be the same as the order activation sequence, and the tickers will be different.

The opening times are always sequential.

It doesn't have any pending orders, but you're right anyway.

For that, it has a function to search for the last open

 
MakarFX #:

It doesn't have any delays, but you're right anyway.

It has a search function for the last open

You need to assemble everything into an array, sort by the right parameter and take from the array by the right index.

 
Vitaly Muzichenko #:

Collect everything into an array, sort it by the right parameter and take it from the array by the right index.

This even sounds scary to me)
 
MakarFX #:
It even sounds scary to me)

And you do things far scarier than you could have done them.

 
Artyom Trishkin #:

And you do things much scarier than you could have done them.

The problem is that not everyone wants to develop. That's quite normal.

Well thanks to you, taught a few years ago to use structure and an array of structure.

Beautifully presented new material itself asks to be studied and applied, the codes turn out many times faster and more beautiful. Not everyone uses such features.

 
Artyom Trishkin #:

And you do things far scarier than you could have done them.

Can you elaborate on that, please? What scary things have I done?