With what to replace OnTradeTransaction() in mql4? - page 5

 
Vitaly Muzichenko:

Today I faced with the fact that one position closed and the other opened on another one, and almost at the same time between ticks.

In the end OrdersTotal() remained at 8. The Expert Advisor's logic got confused - it has not recalculated the new data

That's exactly what I think about and I do not like it. Although my situation will be slightly different, the essence is the same. I'm thinking.

 
Aleksandr Volotko:

That's exactly what I'm thinking and I don't like it. Although my situation will be a little different, but the point is the same. I'm thinking.

Alexander, you won't find anything better than Artem Trishkin's library. Although he's criticizing me, it's just about mql5 and I'm not doing much in mql4 that's why I'm not using that library. I have started one Expert Advisor and tried to use it, but I gave up. The idea turned out to be incompetent before the implementation had been finished... )))

IMHO, building an algorithm on the search of history is not the best option. And changing the size of the history is even worse. One problem has been described by Vitaly. The other is that, if we are not writing only for ourselves, it is generally unacceptable. The number of orders in the history on mql4 depends on the depth selection

And imagine that a user decides to look through the history for today, then for a week and a couple of more switches... The EA would go crazy if it wanted to))))

 
Aleksandr Volotko:

That's exactly what I'm thinking and I don't like it. Although my situation will be a little different, but the point is the same. I'm thinking.

The hash sum of the properties of orders and positions. The symbol is encoded into the sum of the character codes that make up its name. But then only a full loop. When hash sum changes - see what happened.
 
Artyom Trishkin:
The hash sum of the properties of orders and positions. The symbol is encoded into the sum of the character codes that make up its name. But then only a full loop. When hash sum is changed - see what happened.

How's that?

 
Alexey Viktorov:

Alexander, you won't find anything better than Artem Trishkin's library. I don't know why I'm not using it. I've started one EA trying to use it, but I gave it up. I have started one Expert Advisor and tried to use it, but I gave up. The idea turned out to be incompetent before the implementation had been finished... )))

IMHO, building an algorithm on the search of history is not the best option. And changing the size of the history is even worse. One problem has been described by Vitaly. The other is that, if we are not writing only for ourselves, it is generally unacceptable. The number of orders in the history on mql4 depends on the depth selection

And imagine that the user decides to view the history for today, then for a week, and a couple more switches... The Expert Advisor would go crazy if it wanted to))))

Alexei, OrdersHistoryTotal() works clearly, there is always a "Select period" to be filled or deducted.

 
Vitaly Muzichenko:

Alexei, OrdersHistoryTotal() works fine, it always either fills or reduces "Select period"

I don't get it. Are you saying that it doesn't depend on the settings in the terminal? Have there been any such changes?

 
Alexey Viktorov:

I don't get it. Are you saying that it doesn't depend on the settings in the terminal? Have there been any such changes?

No, but maybe we're talking about different things.

static __TotalHist = -1;
int HT=OrdersHistoryTotal();
  if(HT!=__TotalHist)
   {
     SetHistory();
     __TotalHist=OrdersHistoryTotal(); // запомним количество
   }

This will always work.

It might not work in 1 case out of 100,500.

static __Total = -1;
int OT=OrdersTotal();
  if(OT!=__Total)
   {
     SetMarket();
     __Total=OrdersTotal(); // запомним количество
   }
 
Artyom Trishkin:
A hash sum of the properties of orders and positions. The symbol is encoded into the sum of the character codes that make up its name. But then only a full loop. When hash sum changes - see what happened.

give an example in code - this is a necessary feature

 
Alexey Viktorov:

IMHO, it's not the best way to build an algorithm on a search of history.

I didn't even think of touching OrderHistoryTotal(), why?

 
Igor Makanu:

give an example in code - this is a necessary feature

Described in my articles. It is almost at the very beginning. And for MQL4 - in articles about compatibility with 4.
It's hard to give a link from a mobile phone. But if you open any of the recent ones, there's a list of all the articles at the very end.