MT version archive. - page 2

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

The intelligent assumption is that the transfer should be done immediately, without executing the rest of the code. Right?

But in fact TesterStop() does not stop the test at all!

It is expected that if further code execution must be stopped just write return and there will be no further execution. TesterStop(), as well as ExpertRemove()

The Expert Advisor will not stop immediately when ExpertRemove() is called, only a flag is raised to stop the work of the Expert Advisor. I.e., the Expert Advisor will not handle any following event, it will call OnDeinit() and unload it from the chart.

And the second observed flaw is that

tester_stop = false;

it is not in place at all.

 
Alexey Viktorov:

It is supposed to be smart, if you need to stop further code execution, just write return and there will be no further execution. TesterStop() as well as ExpertRemove()

And the second error we have noticed is that

is not in place at all.

The next event is OnTick() ?

Where does OnTick() exit to?

Why is it out of place? It was expected that if TesterStop() was triggered, the execution would not reach this line.

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

The next event is OnTick() ?

Where does OnTick() take the output from?

Why is this not in place? It was expected that if TesterStop() was triggered, the execution would not reach this line.

Where to exit and what to continue is up to the developer.

      if((stop_loss_buy > 0 && stop_loss_buy < 700) || (stop_loss_sell > 0 && stop_loss_sell < 700))
      {
         Print("Результат в OnTester() должен быть -99999999999.99");
         TesterStop();
      }
      check_init  = true;
      tester_stop = false;

The tester_stop flag in this code will set false regardless of whether or not TesterStop() is executed

 
Alexey Viktorov:

Where to go and what to continue is up to the developer.

In this code, the tester_stop flag will take false regardless of whether or not TesterStop() is executed

I've got that already)))

The question is what to do? How to stop the test? To be specific. Developers nearly swear when usingINIT_PARAMETERS_INCORRECT in OnInit() and it blows away genetics.

I've found a way out and had no problems until recently. And now ... Oh, dear ))))

And still where may I get out of OnTick()?

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

I got that already)))

The question is what to do? How do I stop the test? To be specific. Developers nearly swear when usingINIT_PARAMETERS_INCORRECT in OnInit() and it blows away genetics.

I've found a way out but there were no problems lately. And now ... Oh, dear ))))

Well, if you understand what the problem is?

         TesterStop();
      tester_stop = false;
      return;

All code, after executing TesterStop, will not be executed. I.e. it will stop working immediately. Going further, we can adjust the tester_stop flag...

Another question: What is this number? Is minus a lot of nines an attempt to get some additional pain? That's where it gets really ugly...

 
Alexey Viktorov:

Well if you understand what the problem is left?

All code, after executing TesterStop, will not be executed. In other words, it will immediately stop working. From there, we can regulate using the tester_stop flag...

Another question: What is this number? Is minus a lot of nines an attempt to get some additional pain? That's where it gets really ugly...

Minus a lot of nines is to determine that the output was exactly by TesterStop(). I use it only as a substitute forINIT_PARAMETERS_INCORRECT. That's why I don't need everything else after it. But what happens now is that the whole code is executed and the programmer gets the division by zero error. Sure, if an array has size 1, the value of the latter minus the value of the former will always be zero! And I hadn't insured myself against this bug, or, oh, excuse me, misunderstanding.

I tried to insert return... Only a bit wrong ))) :

      if((stop_loss_buy > 0 && stop_loss_buy < 700) || (stop_loss_sell > 0 && stop_loss_sell < 700))
      {
         Print("Результат в OnTester() должен быть -99999999999.99");
         TesterStop();
         return;
      }

I ended up with:

DM      0       15:32:01.518    Core 1  2016.10.01 00:00:00   153128312914612747
PE      0       15:32:01.518    Core 1  2016.10.01 00:00:00   Советник получил MAGIC = 153128312914612747.
IF      0       15:32:01.518    Core 1  2016.10.03 00:00:00   Результат в OnTester() должен быть -99999999999.99
RS      3       15:32:01.518    Core 1  TesterStop() called on 0% of testing interval
GK      0       15:32:01.518    Core 1  final balance 10000.00 USD
JM      0       15:32:01.518    Core 1  OnTester result -99999999999.99001

Just awesome ))))

Greatest THANK YOU!!!

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

Minus a lot of nines is to determine that the output was exactly by TesterStop(). I use it only as a substitute forINIT_PARAMETERS_INCORRECT. That's why I don't need everything else after it. But what happens now is that the whole code is executed and the programmer gets the division by zero error. Sure, if an array has size 1, the value of the latter minus the value of the former will always be zero! And I hadn't insured myself against this bug, or, oh, excuse me, misunderstanding.

I tried to insert return... Only a bit wrong ))) :

I ended up with:

Just awesome ))))

A HUGE THANK YOU!!!

Sergei Tabolin:

Thanks, I got that already. But it doesn't solve the problem. It can be solved either byMQL_TESTER_STOP constant, or by changing the return value from void to bool.

An unexpected solution was suggested byAlexey Viktorov: if return is used after TesterStop(), everything seems to be ok. How and why it happens I personally cannot figure it out. Nevertheless...

Hence, either add this point to the documentation or changevoid to bool.

P.S. I encountered this problem in build 2085. There was no problem before that. Does it say something to me? )))

Sergey, there is nothing unexpected about this. On the contrary, it is logical and consistent. There are different cases. Sometimes you have to finish processing the event before the Expert Advisor is finished, and sometimes, like in your case, you have to finish it right away. 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. And you left it out of my example for some reason.

 
Alexey Viktorov:

Sergey, there is nothing unexpected in it. On the contrary, everything is logical and consistent. There are different cases. Sometimes you have to finish processing the event before the Expert Advisor is finished, and sometimes, like in your case, you have to finish it right away. 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. And you left it out of my example for some reason.

Alexey, thank you very much for your help.

I understand the issue facing the developers and that's why I'm suggesting such a solution. In order to be able to react to the situation correctly.

As for static variables and your example, which I "threw out"... Sorry, but I don't quite understand what we're talking about. Explain it to me, if you don't mind.

And ask for some indulgence and patience. I have a very bad life situation which can make me very irritable (I am aware of that but can't do anything about it) and unattentive.

I'm just not understanding at all. My head is spinning...

Here is an example:

My code shows that if the last array value minus the first array value is early zero, the result must be -9999999999999.88.

But during optimization I get this result:

2019.06.16 16:27:09.847 Core 1  final balance 9587.10 USD
2019.06.16 16:27:09.847 Core 1  OnTester result -99999999999.88

9587 - 10000 is in no way equal to zero and the result is -999999999999999.88. How?!?!? I'm already getting a hang-up...

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

Alexey, thank you very much for your help.

I understand the issue facing the developers and that's why I'm suggesting such a solution. To be able to react to the situation correctly.

As for static variables and your example, which I "threw out"... Sorry, but I don't quite understand what we're talking about. Explain it to me, if you don't mind.

And ask for some indulgence and patience. I have a very bad life situation which can make me very irritable (I am aware of that but can't do anything about it) and unattentive.

I'm just not understanding at all. My head is spinning...

Here is an example:

My code shows that if the last array value minus the first array value is early zero, the result must be -9999999999999.88.

But during optimization I get this result:

9587 - 10000 is in no way equal to zero and the result is -999999999999999.88. How?!?!? I'm getting a hang-up...

I don't know if it's good or bad, but I never get into the whole code, that's why I was talking about a static variable. And judging by the fact that the tester_stop flag is used in different parts of the program, this flag must be declared at the level of global variables.

It confirms that you unreasonably "threw out" changing the flag's value from my example.

This is the use of

   if(tester_stop) return(-99999999999.99);

And apparently this flag either does not change at all, or does not change because the change is not provided where it should be.

 
Alexey Viktorov:
Sometimes it is necessary to terminate event processing before the advisor terminates.

Any programmer has the return operator in his or her arsenal, but there is nothing in the forced termination.


In this context, can't we do a check?

if(IsStopped())
if(!IsStopped())
Reason: