What on earth is going on? - page 2

 

I have a different trick. The adviser puts a sell at the opening of each hour. For euro it works properly, but for custom symbol it is unclear how

In visual mode some candlesticks are missing


Files:
MySymbol.mq5  4 kb
Test.mq5  2 kb
 
Сергей Таболин:

This is once again about the tester/optimiser...

Noticed discrepancies in results of optimisation and single test. Rebooted terminal, changed settings (just to be sure). Started optimization.

Ran a single test...

How could it be? Where does this nonsense come from?

It was the same way. Between optimization passes, variables were not always or not all initialized the way they were before a single pass. I started initializing everything and the problem went away.

Another time I had a similar problem because of iSAR, on minimal steps.

 

One client had a problem. His Expert Advisor was testing and giving results in the tester, but in the optimizer all runs were null.

The algorithm of his Expert Advisor in terms of opening trades was based on reading the caption from the button that changed depending on the situation. Since graphical objects are not rendered during optimization, this request always resulted in a negative result.

If your Expert Advisor's algorithm uses data from graphical objects, there can also be significant differences between the test and optimization.

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


How's that? Both are the same. How can there be a difference? Especially since almost all data is initialized in a loop. And if something is not initialized there, you will get an error.


If you can - elaborate. I would like to see the initialization in the loop. I will show it to my granddaughter.

 
To never do that again.
 
Алексей Тарабанов:

If possible, more details. I would like to see the initialisation in the loop. I will show it to my granddaughter.

int sum = 0;

for ()

  sum = 0;

  for ()

    sum += ....

Or better still, your granddaughter won't understand the meaning:

int sum;

for ()

  sum = 0;

  for ()

    sum += ....
 
Andrey Barinov:
You just need to forget to initialize something in your code and there will be a difference. Check the code.

Checked everything again - all variables are initialised.

@Andrey Kaunov, thanks, but I don't use any graphical objects at all.

Alexei Tarabanov:

If you can - elaborate. I would like to see the initialization in the loop. I will show it to my granddaughter.

For the love of God )))) I overdid it a little - not all of them, of course, but only indicator handles ))))

int      ind_handle[];

int OnInit()
{
...........
   if(!nc_getHandles()) return(INIT_FAILED);
...........
}
//+------------------------------------------------------------------+
bool  nc_getHandles(void)
{
   ind_nums = ArraySize(indicators);
   ArrayResize(ind_handle, ind_nums);

   for(int i = 0; i < ind_nums; i++)
   {
      ind_handle[i]  = iCustom(Symbol(), Period(), folder+indicators[i]);
      if(ind_handle[i] == INVALID_HANDLE)
      {
         Print("Ошибка получения хандла индикатора >>> "+indicators[i]);
         writeErrorFile(program_name,program_version,"Ошибка получения хандла индикатора >>> "+indicators[i]);
         return(false);
      }
   }
   Print("Получены хэндлы всех индикаторов >> ",ArraySize(indicators));
//-----------------------------------
   return(true);
}
 

Now to the point.

Completely cleared all logs and caches.

Started the editor, recompiled the Expert Advisor.

Opened the terminal.

Started the genetic optimization.

Waiting...


Running a single test.

I check if the parameters are correct - they are passed correctly.

I open the Backtest tab.

Profits - 697 / 247

Trades - 44 / 56.

I will now gather logs and attach them.

Files:
mt5logs.zip  288 kb
 

Look into the code and try to figure out what happens to the transactions within the optimisation and with a single walkthrough.

Unprint it, put it in a file yourself.

It's about the logic inside your program. Which no one but you can see and therefore no help will be forthcoming.

 
Renat Fatkhullin:

Look into the code and try to figure out what happens to the transactions within the optimisation and with a single walkthrough.

Unprint it, put it in a file yourself.

It's about the logic inside your program. Which no one but you can see and therefore there will be no help.

Renat, thank you. But explain to me, who doesn't know the difference between 2*2+2*3 in optimizer and single pass? Give at least a hint where exactly there may be a discrepancy?

And, since you mentioned it, give me a hint where and how to find differences between the EA in the Strategy Tester and on a real account?

I, perhaps out of my own stupidity, always believed that the written code (whether it has errors or not, whether it's optimized or not), is compiled, and therefore it should work equally whether in optimizer, or in tester, or on a real account...

Well, simply take the position of an ordinary programmer - where, how and by what means should one look for any unclear difference in execution of one (compiled) code in these three states?

I, as a user, see only that one executable does not work the same in optimizer and tester, which means that in real life it will work the same way .....


A thought occurred to me, what if you're testing an EA and it's... Well, it's no good. What if I use it for real trading? What if it is the Holy Grail? ))))