MT version archive. - page 3

 
Сергей Таболин:

I believe that TesterStop() andExpertRemove() should return true if they cannot immediately pass control to OnTester(). It will allow to react somehow, for example, like this:

bool                 tester_stop = false;                 // флаг проверки выхода по TesterStop
.......
void OnTick()
{
//--- пропустить бесполезные проходы оптимизации
   if(!check_init && (MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)))
   {
      if(недопустимый параметр)          tester_stop = TesterStop();
........
}
double OnTester()
{
   if(tester_stop) return(-99999999999.99);

In this case, we can get exactly the result which is logically expected, instead of dancing around and foreseeing all the errors that can theoretically occur as a result of stopping the test.

And this is the option you wanted to see.

bool                 tester_stop = false;                 // флаг проверки выхода по TesterStop
.......
void OnTick()
{
//--- пропустить бесполезные проходы оптимизации
   if(!check_init && (MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)))
   {
      if(недопустимый параметр)
       {
        TesterStop();
        tester_stop = true;
        return;
       }
........
}
double OnTester()
{
   if(tester_stop) return(-99999999999.99);
 
Roman:

In this context, can't we do the checking?

And how do we prevent/cancel the forced termination if it's already running? Your examples are a bit different.
 
Alexey Viktorov:
And how do you prevent/cancel the forced termination if it's already running? Your examples are a little different.

Don't trigger a forced termination. Then there is no need to cancel it.

Probably, forcing completion that is already running, cancelling it does not make sense because of possible software glitches.
For this reason, it is likely that there is no such possibility. I can't say for sure.
This means that we should logically arrange our code in such a way that we would not need to get back to the running code again when the forced termination is launched.
If we quit, we quit explicitly.

 
Roman:

It is unlikely that a forced termination already running would make sense to cancel due to possible software glitches.
Therefore, there is probably no such option. I cannot say for sure.
This means that we should logically arrange our code in such a way that we would not need to get back to the running code again if we run a forced termination.
If we quit, we quit explicitly.

Somehow I get the impression that you haven't read everything in the topic. Something doesn't quite coincide with your opinion of the problem at hand.

ps; Although no. In your first post of this thread you seemed to quote my exact words, but not completely. Maybe because of it the whole idea of the problem shifted.
 
Whatever the questions, that's what the answers are. Talk to yourselves, then. You try to get into the problem and people still don't like it. Good luck finding the problem.
 
Alexey Viktorov:

And this is the version you wanted to see.

That's right.

But isn't

if(недопустимый параметр)          tester_stop = TesterStop();

simpler and clearer than...

if(недопустимый параметр)
       {
        TesterStop();
        tester_stop = true;
        return;
       }

?

But now I have done exactly as you advised.

 
Roman:
Such questions and such answers. You may discuss it with yourselves. You try to get into a problem and people still don't like it. Good luck finding the problem.

You shouldn't be offended. You had to read the whole sentence in order to understand it.

Forum on trading, automated trading systems and testing trading strategies

MT version archive.

Alexey Viktorov, 2019.06.16 15:25

Sergey, there is nothing unexpected. On the contrary, everything is logical and consistent. There are different cases. Sometimes you have to complete the event processing before the Expert Advisor finishes its work, sometimes, like in your case, you have to finish it urgently. The developers are faced with the question, what is the right thing to do, to stop immediately, causing discontent of those who need to finish processing the event, or to stop after the completion of event processing. Any programmer has return operator in his/her arsenal, while there's nothing in case of forced termination.

And why do you need to change the void type on the bool, because again, in the arsenal of the programmer there are static variables that can be changed before or after TesterStop (), and in principle, everything will be as you want. But you have omitted it from my example for some reason.

and you only took the second part out of context without paying attention to the first part.
 
Сергей Таболин:

That's right.

But isn't it

simpler and clearer than...

?

But now I have done exactly as you advised.

It may be simpler and clearer, but demanding from developers something that can easily be written yourself is wrong. For some reason I don't believe that any additions to the language are written about C++ and demanded. And the remarks, I'm sure, are enough for many.

 
Alexey Viktorov:

It may be simpler and clearer, but it's wrong to demand from developers something that can easily be written by themselves. For some reason, I don't believe that any additions to the language are written about C++ and demanded. And the remarks, I'm sure, are enough for many.

Here's a check on your option. It ended up with a message like this:

2019.06.16 18:49:25.464 Core 1  TesterStop() called on 0% of testing interval

It's a dead end...

 
Alexey Viktorov:

You shouldn't be offended. You had to have the whole phrase in order to understand it.

and you only took the second part out of context without paying attention to the first part.

By giving an example with IsStopped(), I was trying to answer the first part.
Sometimes it's necessary to complete processing of the event before completing an EA, sometimes it's urgent like in your case.
Read the description of this function IsStopped() in documentation, maybe it will lead to some ideas.
But it seems to you it's from another direction. If so, sorry for a possible guess.
But as they say in possible suggestions, and solves the problem.
Definite solution will not tell anyone, because no one knows all the logic of his code, and probably will not delve into it.

Reason: