Any questions from a PROFI to a SUPER PROFI - 1. - page 43

 
fxsaber:

I don't get it. If something has changed in the database, the only way to find out is to compare it with the previous state of the database.

You can compare each corresponding database element. Or you can calculate the hash from them and compare the hashes.

The terminal already knows about this change (OnTrade). That's why I want to know about it in my function.

 
fxsaber:

Especially relevant for MT4, where the time_msc step change is 1000ms.

Too bad, it makes it impossible to use the simplest option I know at the moment.

 
Andrey Khatimlianskii:

The terminal already knows about this change(OnTrade). That's why I want to know about it in my function.

There is no Trade event in MT4.

 
fxsaber:

The trade event is not in MT4.

It just hasn't been routed to MKL. The terminal does not update the list of trades on a timer.

 
Andrey Khatimlianskii:

It just hasn't been wired into the MCL. The terminal does not update the list of trades on a timer.

Therefore, only through verification.

 
Andrey Khatimlianskii:

1. What is the cheapest way to know that the function call is on the same tick as the previous call?

Time (TimeCurrent) can stay the same, time in ms from SymbolInfoTick, theoretically too.

Comparing the bid, ask and ms times is quite expensive.

I do not suggest organizing the control in the Expert Advisor itself, I want to get a universal independent function.


The same question concerns trading operations. How do we know that something has changed in the list of orders/positions (including the open levels, SL and TP) since the last run?

I would need to set some flag in OnTrade (and reset it when done), it's the cheapest way to do it.

But, again, I would like a universal solution.


Who has any ideas?

Right:

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   int count = 0;
   if ( A ) some_func( count );
   if ( B ) some_func( count );
   if ( C ) some_func( count );
}
//+------------------------------------------------------------------+
void some_func( int& count )
{
   if( count++ > 0 )
      return;
      
   // recalculate only once on each tick
}
//+------------------------------------------------------------------+
 
Koldun Zloy:

Okay:

Thank you.

Andrey Khatimlianskii:

I don't suggest the option of organizing control in the EA itself, I just want to get a universal independent function.

 
Andrey Khatimlianskii:

Thanks.

Since it hasn't been suggested yet, I'll give you an idea where I'd dig, check the time of the last PostMessage or something, probably nonsense, I'm not that versed in Api.

 
Aleksey Mavrin:

Checking the time of the last PostMessage or something like that is probably nonsense, I don't know that much about Api.

Yes, it looks like nonsense)

Thanks for trying.

 
Andrey Khatimlianskii:

Unrealistic without control in the EA itself.

Not only that, it is not necessary. The requested function will be called in the EA, i.e. it is essentially the same control in the EA, only less invasive

Reason: