Errors, bugs, questions - page 307

 
Jager:

When trying to test on usdjpy I get a message like this:

and seems to go on indefinitely, when it got to 3000 I turned it off. Tests tried to switch on 2010.10.01 - 2010.10.10, only opening prices.

bild 401

Also can't get another remote agent to start, here's the log:

also observed a similar pattern yesterday... Looks like the whole story was overloading and apparently there were some problems in doing so.

I seem to have waited until the end of the process or restarted the terminal.

found an interesting thing yesterday. after recompiling the EA, the changes don't work in the tester until you restart the terminal - that's the tin!!!

 
Im_hungry:
Fully supportive - maybe servicedesk? (close it a hundred times)
what's the point ? they all know perfectly well...
 

As of yesterday, the experts have started to live their digital lives.

When testing it gives out a random focus... It skips OnInit() function in some magic way, then it generates error array out of range in DeInit() function.


The thing is that with the same parameters it may start and run the whole test, or it may crash.

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
Im_hungry:

Here's the challenge: make the indicator parameter dynamic, when you close a position you change one of the indicator parameters, so that's the challenge.

Now my solution:

I can say that this code works as testing shows a different result, but it's not clear why it works t.s. once in a while, I looked in the log - 1 week everything works as it should, then it loops and outputs the same values in the buffer, although this is impossible (2 weeks the same values in the tester log), if not loops then just writes an error:

message via Alert

As far as I could understand, the Expert Advisor creates a handle of some indicator when a new bar appears and at the same time it requires to copy the buffers of this indicator. But this does not work out the situation when it may take some time to calculate the indicator buffers. In other words, the indicator handle may be successfully created, but the indicator buffers haven't been calculated yet.
Усреднение ценовых рядов без дополнительных буферов для промежуточных расчетов
Усреднение ценовых рядов без дополнительных буферов для промежуточных расчетов
  • 2010.10.25
  • Nikolay Kositsin
  • www.mql5.com
Статья о традиционных и не совсем традиционных алгоритмах усреднения, упакованных в максимально простые и достаточно однотипные классы. Они задумывались для универсального использования в практических разработках индикаторов. Надеюсь, что предложенные классы в определенных ситуациях могут оказаться достаточно актуальной альтернативой громоздким, в некотором смысле, вызовам пользовательских и технических индикаторов.
 
Yedelkin:
As far as I was able to understand, the Expert Advisor creates some indicator handle when a new bar appears and at the same time it requires to copy the buffers of this indicator. But the situation is not worked out, when the calculation of indicator buffers may take some time. In other words, the indicator handle may be successfully created, but the indicator buffers haven't been calculated yet.

Yes I agree - that's why I tried this design:

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{ 
   if (isNewBar()==true && proverkaHANDLA()==true)
     {
      if (!PositionSelect(Symbol1) && !PositionSelect(Symbol2))
         {
          BSOpen();
         }
     }    
}
//+==================================================================+
bool proverkaHANDLA()
{
  ArraySetAsSeries(Sp1Buffer,true);
  ArraySetAsSeries(Sp2Buffer,true);
//----------------------
  vhandle=iCustom(NULL,0,"МТ5",Symbol1,100,Lots,1,Close());
  if(vhandle<0)
    {
     Alert("Ошибка при создании индиката: ",GetLastError());
     return(0);
    }
  if(CopyBuffer(vhandle,0,0,50,Sp1Buffer)<0 || CopyBuffer(vhandle,1,0,50,Sp2Buffer)<0)
    {
     Alert("Ошибка копирования буферов индикатора номер ошибки:",GetLastError());
     return(0);
    }
  return (true);
}

It works for now! Thank you for your help

 

But every once in a while it gives out:

Alert: Ошибка копирования буферов индикатора номер ошибки:4806
 
Im_hungry:

Yes I agree - that's why I tried this design:

It's working so far! Thank you for your help

Such a construct skips cases when "the handle has been created, but indicator buffers have not been calculated yet". Since the construction itself is called once per period, you can try to call the CopyBuffer() function multiple times. I.e. if CopyBuffer()<0, then repeatedly call the function, as long as the selected period allows (within the selected time period).
 
Im_hungry:

But every once in a while it does:

Well, that's right. Your function proverkaHANDLA() is independent block, which internally refers toCopyBuffer() only once.Accordingly, if the buffers are not calculated, it will always pop up again. So far your function proverkaHANDLA() does not handle the "handle created, but indicator buffers not calculated yet" situation, but ignores it.

 
Yedelkin:
This construction skips cases, when "the handle has been created, but the indicator buffers have not been calculated yet". Since the construction itself is called once per period, you can try to repeatedly call the CopyBuffer() function. I.e. if the CopyBuffer()<0, then repeat the function call, as long as the selected period allows (within the selected time period).

That is, while CopyBuffer>0 we calculate it, and the new parameter (Close()

appears at closing of the position. That is, we need to loop through While. It turns out like this.

if(!PositionSelect(Symbol1) && !PositionSelect(Symbol2))
  {
   While (vhandle>0)
    {
     if(CopyBuffer(vhandle,0,0,50,Sp1Buffer)<0 || CopyBuffer(vhandle,1,0,50,Sp2Buffer)<0)
      {
       Alert("Ошибка копирования буферов индикатора номер ошибки:",GetLastError());
       return(0);
      }
    }
  }
 
Try reading about BarsCalculated in the help, which, by the way, gives the right example.