[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 383

 
Hi all !!!!!
Question how to find the most recent losing order ???
What is the principle ??? Is it an open-price order or is there any other way ?????
 
VOLDEMAR:
What's the principle ??? Order Open Price ??? or is there any other way ????

OrderProfit()
 
drknn:

OrderProfit()
What ??? OrderProfit() Could you be more specific???
 
artmedia70:

You connect this library to the EA. At the very beginning of the code, write it after the standard libraries are connected:

In the EA, in the start() function, make a call to the function that is in the library and compile the EA, not the library.


I did everything like you said and now when compiling the EA, it gives out cannot open the program file and points to the line with the name of my function: #include <GetExstremumZZZPrice.mqh>
 
VOLDEMAR:
What ??? OrderProfit() Can you be more specific???
In the for() loop, start going through the orders in order, but from the end using the OrderSelect() function and the MODE_HISTORY parameter. Once you have found a losing order using the OrderProfit() function, call break(). You have found what you were looking for!
 
Explain what OrderCloseBy is it clear that one order is different, and what does it do?
 
T-G:
Explain what OrderCloseBy is it clear that one order is different, and what does it do?
It gives a small saving on the spread.
 
splxgf:
This gives a small saving on the spread.

At a rough guess, it is exactly twice as much.
 
VOLDEMAR:
What ??? OrderProfit() Could you be more specific???

We declare a variable of datetime type (e.g. Ord_Time) and immediately set it to zero. We declare an integer variable, e.g. Ticket, and then clear it too. Then we create a loop that will loop through all of the orders from the history. The next order has been selected. If the time of its closing is higher (or equal) than that in the Ord_Time variable and OrderProfit() is less than zero, the Ord_Time variable =OrderCloseTime() and the Ticket variable =OrderTicket(). As a result of this loop, the Ticket variable will contain a ticket of the last losing order, or zero, if there are no losing orders in the history at all.
 
drknn:

Declare a datetime variable (e.g. Ord_Time) and immediately set it to zero. We declare an integer variable, e.g. Ticket, and set it to zero as well. Then we create a loop that will loop through all of the orders from the history. The next order has been selected. If the time of its closing is higher (or equal) than that in the Ord_Time variable and OrderProfit() is less than zero, the Ord_Time variable =OrderCloseTime() and the Ticket variable =OrderTicket(). As a result of this loop, the Ticket variable will contain a ticket of the last losing order, or zero, if there are no losing orders in the history at all.

Why make things so complicated?

Run the following script:

int start()
{
   for (int Pos = OrdersHistoryTotal()-1; Pos >= 0; Pos--)
      if(OrderSelect(Pos, SELECT_BY_POS, MODE_HISTORY))
      {
         Print(OrderTicket(), ": ", TimeToStr(OrderCloseTime()));
      }
}

I wrote the solution above. You only need to insert one line in this code.