What on earth is going on? - page 5

 
Andrey F. Zelinsky:

declare a variable globally and initialize it at declaration, e.g. int kk=0;

then in OnTick() unprint and change value, e.g. Print("kk=",kk); ++kk;

then change TF -- and see the result.

it's clear that the global variable will retain its value even if the TF is changed - but nothing like that happens in the tester.

 
Andrey Dik:

it is clear that the global variable will retain its value even if the TF is changed - but nothing like that happens in the tester.

Now you have found the answer to the cause of the difference in the results.

When optimizing, parameters are re-selected, i.e. the Expert Advisor is restarted with different settings.

 
Andrey F. Zelinsky:

Now you've found the answer to the difference in results.

Do you think that the global EA variable retains its value from past optimiser runs and is carried over to the next ones?

 
Andrey F. Zelinsky:

check it, it's easier to check than guess.

Renat above wrote that the optimizer works "like clockwork" and that the reason is in the code -- he recommended several times to do an unpriming -- I assume that no one has done it.

have you checked it yourself? any clear examples of when a single run will work differently than as part of optimization?

for example, i remember, removing a handle in the tester didn't work before, it caused memory overflow and terminal crash along with the system. maybe this problem has been solved already but there are still some pitfalls with creation and removal of indicator handles and there are differences in optimizer and single indicator runs. as i know developers worked very hard to speed up and minimize memory consumption wherever possible.

 
Andrey Dik:

have you checked it yourself? are there clear examples in which cases a single run will work differently than as part of the optimisation?

in this case it is not a single run.

 
Andrey F. Zelinsky:

Check initialization of globally declared variables.

If initialization is not in OnInit(), but in declaration and if their values are changed in the code.

  1. I checked it.
  2. That's what variables are - they can be changed.
  3. Correct me if I'm wrong.
  • If a variable is defined, memory is reserved for it.
  • If it's not initialized, anything may be stored in it.
  • What's the difference between initializing it by zero right away or assigning the result of calculations in a certain place?
  • If you try to use an uninitialized variable, the compiler will generate a warning.

A simple example:

int tst(int x)
{
   int y;
   if(x >= 0)  y = 1;
   else
   if(x < 0)   y = 0;
   return(y);		// possible use of uninitialized variable 'y'
}

Although.... The compiler doesn't generate the warning for some reason if you put the declaration into the global scope (((

int y;

int tst(int x)
{
   if(x >= 0)  y = 1;
   else
   if(x < 0)   y = 0;
   return(y);           // никакого предупреждения уже нет...
}
'test.mq5'
code generated
0 errors, 0 warnings, 143 msec elapsed

I was expecting something different...

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

  1. I checked.
  2. Variables are just that, variables, they can be changed.
  3. Correct me if I'm wrong.
  • If a variable is declared, memory is reserved for it.
  • If it's not initialized, anything may be stored in it.
  • What's the difference between initializing it by zero right away or assigning the result of calculations in a certain place?
  • If you try to use an uninitialized variable, the compiler will generate a warning.

A simple example:

Although.... The compiler doesn't generate the warning for some reason if you put the declaration into the global scope (((

I was expecting something different.

The fifth page was going on, but there was still no mql5 code... There also remains a mystery shrouded in darkness regarding testing: symbol(s), timeframe(s), testing settings.

 

Well, one more question before I start priming.

For example, I have recorded the results:

optimizer - buy;sell;sell;buy;buy;sell

tester - buy;sell;sell;buy;buy;sell;buy;buy;sell

How can the data on these"extra" deals help to understand what ceiling they came from? Perhaps we should write the prices of previous bars as well, or what else?

 
Vladimir Karputov:

The fifth page was going on, but the mql5 code still wasn't there... There also remains a mystery shrouded in darkness regarding testing: symbol(s), timeframe(s), testing settings.

Welcome back from holiday ))))

You can see everything here.

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

  1. I checked.
  2. Variables are just that, variables, they can be changed.
  3. Correct me if I'm wrong.
  • If a variable is declared, memory is reserved for it.
  • If it's not initialized, anything may be stored in it.
  • What's the difference between initializing it by zero right away or assigning the result of calculations in a certain place?
  • If you try to use an uninitialized variable, the compiler will generate a warning.

A simple example:

Although.... The compiler doesn't generate the warning for some reason if you put the declaration into the global scope (((

I was expecting something different...

If 'x' is of the double type, the given examples are fundamentally wrong and the 'y' state is undefined in both cases

that is, it is possible that somewhere in the depths of neural networks one may get either special double values - inf-types, nan-types or similar to eps-values

Документация по MQL5: Основы языка / Типы данных / Вещественные типы (double, float)
Документация по MQL5: Основы языка / Типы данных / Вещественные типы (double, float)
  • www.mql5.com
Вещественные типы (или типы с плавающей точкой) представляют значения, имеющие дробную часть. В языке MQL5 есть два типа для чисел с плавающей точкой. Способ представления вещественных чисел в машинной памяти определен стандартом IEEE 754 и не зависит от платформ, операционных систем и языков программирования. Константы с плавающей точкой...
Reason: