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

 
MakarFX:

but I've tried it this way.

What function should I use next to go through the closed positions?

 
Amon1953:

Which function should I use next to go through the closed positions?

And what should be done with the found orders in general?
 
MakarFX:
What should be done with the found orders anyway?

I need to find the last closed SL position to make a decision

if(HistorySelectByPosition(ORDER_MAGIC==1))

{

int PosTotal= ??? which function to use?

Alert("PosTotal ",PosTotal);

for(int i=PosTotal-1; i>=0; i--)

{

Alert("PositionsTotal ",PosTotal);

}}


 
Amon1953:

I need to find the last closed SL position to make a decision

There is a huge difference between

a) Find out if the last position closed at stop, and

b) Find the last position closed by a stop.

--------

What do you need?

 
Amon1953:

I need to find the last closed SL position to make a decision

I'm not good at MQL5, but I think the search should start like this

      if(HistoryOrderSelect(ticket))
        {
         if(HistoryOrderGetInteger(ticket,DEAL_TIME)>=CurrentTime)
           {
            if(HistoryOrderGetInteger(ticket,DEAL_MAGIC)==Magic)
              {
               if(HistoryOrderGetInteger(ticket,DEAL_TYPE)==DEAL_TYPE_BUY)
 
MakarFX:

I'm not good at MQL5, but I think the search should start like this

I need a closed position, not a trade or order

 
Amon1953:

I need a closed position, not a trade or order

Confused

HistoryOrderSelect


 
MakarFX:

Confused

HistoryOrderSelect


How can a warrant help?

 
Artyom Trishkin:

How can a warrant help?

The original question was

Amon1953:
This is probably a simple and naive question, but I've already racked my brain aboutHistorySelectByPosition(ORDER_MAGIC==1) I needa history of positions with magic = 1. Something I don't understand. Whatever I do, I don't get the history. Where should I enter the number of a magician?
      if(HistoryOrderSelect(ticket))
        {
         if(HistoryOrderGetInteger(ticket,ORDER_MAGIC)==Magic)


 
MakarFX:

The original question was.


In five, order !=position. And a transaction. An order (order) generates a trade. And a deal gives rise to a position, either changing it or closing it.

Accordingly, to find how a position was closed, you need to select the trades of this position, find the closing trade and look at its properties - the reason for closing may be specified there.