Errors, bugs, questions - page 343

 
Kairoser:

Good afternoon!

After upgrading to 420 release I started to test my EA and noticed that it started "losing" for some reason. I analyzed my trades and noticed that stop loss is triggered at non-existent prices. For example, I set stop loss at 1.06520 on EURUSD, but it works, although the maximal price is 1.05920. When I look further, I see a lot of such deals. Take Profit is triggered by the same principle (at non-existing prices) - the delta is the same - 600 points. In the tester on the chart the up and down arrows "hang" in the air, far from bars.

A screenshot is attached.

Run tests on MetaQuotes-Demo, please. Alpari has a blatantly erroneous (in spreads) chart history.
 
Renat:
Run tests on MetaQuotes-Demo, please. Alpari has a blatantly wrong (in spreads) chart history.
Yes indeed, everything works fine on the MetaQuotes-Demo server. Thanks for the help.
 

A couple of questions are of interest.

1. If indicators are used in the strategy tester, how does the system work? First, all indicators for which handles are calculated and only then OnTick is launched?

2. If yes, it would be good to start OnTick first and then run a command to calculate the attached indicators. Thus, for example I don't need to calculate indicators on every five-digit tick, but only on four-digit. When I start OnTick, I check the current and previous price and decide whether to start calculation of indicators or not.

Because if there are a lot of them and they are quite "heavy", they consume resources in optimization mode...

Although, you may try to create handles in ontick and delete indicators at the end and at the next start of ontick (if necessary) create handles again - and it's not clear whether it will improve performance...

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

A couple of questions are of interest.

1. If indicators are used in the strategy tester, how does the system work? First, all indicators for which handles are calculated and only then OnTick is run?

Yes. The more general answer - all indicators values are calculated before each call of the event handler:

  • OnTick
  • OnTimer
  • OnChartEvent and so on
 
olyakish:
2. If yes, then it would be very useful to run OnTick first and then run the calculation of attached indicators with this command. For example I don't need to calculate indicators on every five-digit tick, but only on four-digit. When I start OnTick I check the current and previous price and decide whether to start calculation of indicators or not.

Because if there are a lot of them and they are quite "heavy", they eat up resources in optimisation mode...

You can't do that. You can use faster tick generation modes for testing:

  1. OHLC prices on minute bars
  2. Only open prices of the period being tested
 
Rosh:

You can't do it this way. You can use faster tick generation modes for testing:

  1. OHLC prices on minute bars
  2. Opening prices of the period under test only
I know about those modes and their peculiarities. I just wanted to speed up the optimization in a reasonable (probably optimal) way.
 

Help out, data conversion functions don't want to work, wrote a simple script to test it. Build 420, 64 bit OS.

void OnStart()
  {
//---
   int i=0;
   bool res=false;
   string stroka1;
   string stroka2;
   string stroka3;
   string stroka4;
   string stroka5;

   datetime buf1;
   double   buf2;
   double   buf3;
   double   buf4;
   double   buf5;
   
   int filehandle=FileOpen("56451.csv",FILE_READ|FILE_CSV|FILE_ANSI,',',CP_UTF8);

   if(filehandle==INVALID_HANDLE)Print("Ошибка № - ",GetLastError());
   else
     {

      while(!res)
        {
         stroka1 = FileReadString(filehandle);
         stroka2 = FileReadString(filehandle);
         stroka3 = FileReadString(filehandle);
         stroka4 = FileReadString(filehandle);
         stroka5 = FileReadString(filehandle);

         buf1 = StringToTime(stroka1);
         buf2 = StringToDouble(stroka2);
         buf3 = StringToDouble(stroka3);
         buf4 = StringToDouble(stroka4);
         buf5 = StringToDouble(stroka5);

         res=FileIsEnding(filehandle);
         i++;
        }
      FileClose(filehandle);
     }
  }
//+------------------------------------------------------------------+
Files:
56451.zip  16 kb
 
sergey1294:

Help out, data conversion functions don't want to work, wrote a simple script to test it. Build 420, 64 bit OS.


Get rid of the quotes at any stage....
 
AlexSTAL:
Get rid of the inverted commas at any stage....
How do you do that?
 
sergey1294:
How do you do this?

Either make sure they are not initially in the file, or apply an additional function when reading, for example:

string StringWithoutQuotes(string Value)
{
   StringTrimLeft(Value);
   StringTrimRight(Value);
   return(StringSubstr(Value, 1, StringLen(Value) - 2));
}

..........

         stroka1 = StringWithoutQuotes(FileReadString(filehandle));
         stroka2 = StringWithoutQuotes(FileReadString(filehandle));