How can i find out what configuration was used for a certain pass during backtest optimisation?

 
Hi
During certain pass while performing backtest using genetic algo and custom max criterion i got error:

genetic pass (0, 110) tested with error "critical runtime error 502 in OnTester function (array out of range, module Experts\XXXX.ex5, file XXXX .mq5, line 4013, col 72)" in 0:00:02.762

1. How can i find this genetic pass configuration so that i can reproduce the error and fix it?
2. Is there a log file created for each genetic pass? Where would that be kept?

3. Also i am using few mqh header file with some logic in this XXXX.mq5 EA file. Does the 4013 line number refer to the line within XXXX.mq5 file or the line number within combined logic once headers are included in XXXX.mq5 file?


The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
 
Catch the the error before it happens and let OnTester() return a unreal big number. Then this configuration will be placed at the very top of the results. The you can run this in a single pass.
 
Carl Schreiber #:
Catch the the error before it happens and let OnTester() return a unreal big number. Then this configuration will be placed at the very top of the results. The you can run this in a single pass.
Hi, but to catch the error i need to find which line of code it occured at.

For that reason i was asking if the line number in the error represents the actual line number in the mq5 file or it represents the line number after header file's code (in mqh file) has been added to the main EA mq5 file?
 
Varun Maithani #:
Hi, but to catch the error i need to find which line of code it occured at.

For that reason i was asking if the line number in the error represents the actual line number in the mq5 file or it represents the line number after header file's code (in mqh file) has been added to the main EA mq5 file?
  1. I thought you were asking for the special configuration as function line and column are logged: "OnTester function (array out of range, module Experts\XXXX.ex5, file XXXX .mq5, line 4013, col 72)"
  2. Do you know/have the source code?
  3. Most probably there is an array, so check the access.
 
Carl Schreiber #:
  1. I thought you were asking for the special configuration as function line and column are logged: "OnTester function (array out of range, module Experts\XXXX.ex5, file XXXX .mq5, line 4013, col 72)"
  2. Do you know/have the source code?
  3. Most probably there is an array, so check the access.
yeah i did check the source code. the wierd thing is that the line number is not within the ontester function.
The line number is within a different function which has some array. i will try to catch error there and see if it is caught.
Ontester function does not call that different function so thats why i was asking my questions.
i will see if trying  to catch error in that different function helps first 
 
Varun Maithani #:
yeah i did check the source code. the wierd thing is that the line number is not within the ontester function.
The line number is within a different function which has some array. i will try to catch error there and see if it is caught.
Ontester function does not call that different function so thats why i was asking my questions.
i will see if trying  to catch error in that different function helps first 

unfortunately even when i tried to catch the error before it occured, it was not caught. I am not sure what other way is there to find out the pass in which this error occured. Does anyone know how they solved such issue?

is there a log file stored for every pass?
 
when array out of range error occurs , then according to this webpage, 
https://www.mql5.com/en/docs/runtime/errors

program is terminated immediately.

1. When it is terminated is deinit function called or not? Is ontester method called?

2. Why is array out of range error not present in these errorcodes?
https://www.mql5.com/en/docs/constants/errorswarnings/errorcodes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
  • www.mql5.com
GetLastError() is the function that returns the last error code that is stored in the predefined variable _LastError . This value can be reset to...
 
Varun Maithani #:
yeah i did check the source code. the wierd thing is that the line number is not within the ontester function.
The line number is within a different function which has some array. i will try to catch error there and see if it is caught.
Ontester function does not call that different function so thats why i was asking my questions.
i will see if trying  to catch error in that different function helps first 

Line numbers belong to specific files - exactly as reported. No one could debug a code if errors would be marked by hypothetical line number of combined source codes with all includes (for which order of includes are even hard to follow).

According to your words, the error occured somewhere on the stack during OnTester event handler call, so your words that the problematic lines do not called from OnTester seems incorrect.

If you have the source code, just find the line and make sure (through edit) the access to an array is protected with index checkup.

If you don't mind to use autotranslation from Russian, then there is a solution for finding out problematic passes during optimization.

CheckInputs - нахождение аварийных проходов при Оптимизации советника
CheckInputs - нахождение аварийных проходов при Оптимизации советника
  • 2025.02.22
  • www.mql5.com
Во время Оптимизации советника некоторые проходы могут завершаться аварийно. Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий Новая версия платформы MetaTrader 5
 

I have found the issue and fixed it. It was in a different method than ontester.

The line number was indeed correct although it was a bit tricky to troubleshoot since i didnt know that performing testerstop call doesnt stop the program immediately but waits for the whole tick to be processed, it took me a while to figure that out and then fix the issue.


But the method ontester is misleading, atleast in my case it was misleading,  i dont know why.

Anyways issue resolved. 

thanks for the link ill check it out