1 (edited by Irmantas 2017-11-20 12:23:05)

Topic: "Critical runtime error 502 ..." mt5 tester

Hi,
I want to run optimization tests with mt5 only open prices. I get this error with different strategies, but with some strategies everything is OK. Also with some strategies tester does not launch at all. It points to the same code line. So where is a problem? Is it my local mt5? Or I need to fix something in mq5 file? To add more, it seems if I uncheck some parameter optimization boxes and leave only TP and SL error disappear.

2017.11.20 13:05:46.676    Core 01    pass 1846 tested with error "critical runtime error 502 in OnInit function (array out of range, module Experts\2 EUR USD 60 (1).ex5, file 2 EUR USD 60 (1).mq5, line 1999, col 24)" in 0:00:00.094

If you wonder why the hell I want to optimize with mt5, the answer is:  I need to have thousands of test with different parameters. Wanna check some stuff like parameter sweep and parameter permutation test to fight data mining bias. If you know how to run thousands of test with different parameters automated way with FSB please share smile

Post's attachments

2 EUR USD error.xml 14.9 kb, 1 downloads since 2017-11-20 

You don't have the permssions to download the attachments of this post.

Re: "Critical runtime error 502 ..." mt5 tester

mql5 file attached if needed.

Post's attachments

2 EUR USD error.mq5 260.11 kb, 3 downloads since 2017-11-20 

You don't have the permssions to download the attachments of this post.

3 (edited by sleytus 2017-11-20 13:53:49)

Re: "Critical runtime error 502 ..." mt5 tester

I've seen this error before in *.mq4 source files, as well.  I have a workaround, but I do not know why it happens with some strategies and not others.  Until Popov comes up with a permanent solution I'll show my workaround below.  And, actually, there are probably 4 more methods that run into the same problem.  The error message tells you which line the error occurs (e.g. in this case line 1999).  If a similar error occurs in other methods then you can apply a similar workaround.

I am not claiming this is an elegant solution -- only that it is good enough to keep the strategy up and running.


/////////////////////////////////////////////////////////////////////////////
// This is the original code...
void Indicator::BandIndicatorLogic(int firstBar,int previous,const double &adUpperBand[],const double &adLowerBand[],
                                   IndicatorComp &indCompLong,IndicatorComp &indCompShort,BandIndLogic indLogic)
  {
   double sigma=Sigma();
   firstBar=MathMax(firstBar,2);

   for(int bar=0; bar<firstBar; bar++)
     {
      indCompLong.Value[bar]  = 0;
      indCompShort.Value[bar] = 0;
     }



/////////////////////////////////////////////////////////////////////////////
// This is the modified code...
void Indicator::BandIndicatorLogic(int firstBar,int previous,const double &adUpperBand[],const double &adLowerBand[],
                                   IndicatorComp &indCompLong,IndicatorComp &indCompShort,BandIndLogic indLogic)
  {
   double sigma=Sigma();
   firstBar=MathMax(firstBar,2);

   int iSize_CompLong = ArraySize(indCompLong.Value);
   int iSize_CompShort = ArraySize(indCompShort.Value);
   if (MathMin(iSize_CompLong, iSize_CompShort) < firstBar)
   {
      firstBar=MathMin(iSize_CompLong, iSize_CompShort);

   }


   for(int bar=0; bar<firstBar; bar++)
     {
      indCompLong.Value[bar]  = 0;
      indCompShort.Value[bar] = 0;
     }

Re: "Critical runtime error 502 ..." mt5 tester

Thank you Sleytus for your help smile It worked, at least for this strategy.
If you or somebody else are interested what I try to research links are below:

Parameter sweep - interview (https://www.youtube.com/watch?v=JjXw9Mda7eY) , blog parts 5 6 7 8 (http://aaaquants.com/2017/08/25/quant-b … ter-sweep/)

System Parameter Permutation - interview (https://www.youtube.com/watch?v=B4ScXtiM3OE), original paper (http://www.statistrade.com/support-file … walton.pdf)

These methods promise to fight and reduce data mining bias (reason why great backtest do not produce nothing similar in the future).  Will see if something positive come out smile For now I am not so sure if using big parameter step is OK. Forced to use big one with mt5 optimizer. The best thing would be that mt5 optimizer would run from multi million parameter space randomly, and I just stop manually after some thousand. However it runs with some order and I don't get all parameters changed, so I am forced to use big step and not so big parameter space... The problem here is that I get one parameter with replicated same ~5-10 values many times. Will see if this would not be major obstacle to produce test results. Everything else I think is doable with MS Excel. Actually the best thing would be to collect data with FSB. However I think it is not possible to do it, without custom  functions. What data I need is in image linked.
https://prnt.sc/hdaq2i

Have a nice day!

5 (edited by Irmantas 2017-11-30 15:53:25)

Re: "Critical runtime error 502 ..." mt5 tester

Hi,
I am still struggling with this error while using mt5 tester. Sleytus fix does not work out always, but about half cases it solves it smile  I attached some example with HMA indicator. I think there is some problem with bigger periods. In example 40 HMA period works fine, with 140 period it stops. Maybe something with min bars needed?

https://s33.postimg.org/k0itb3irf/error_test.png

After applying Sleytus fix red error stops, however HMA indicator is not working either.
Would be very nice if someone suggest solution what to do.

Post's attachments

test error HMA.mq5 257.52 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: "Critical runtime error 502 ..." mt5 tester

FSBpro file attached if needed.

Post's attachments

test error HMA.xml 13.78 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

7 (edited by Irmantas 2017-12-01 09:10:47)

Re: "Critical runtime error 502 ..." mt5 tester

It somehow related with indicator max period. Found that in another strategy with Arron Histogram it comes after 150 period. Until that everything is OK. After Sleytus fix applied error stops, however EA stops producing entries. So the question is, what period limits are used? Where I can find them for individual parameters? Maybe this error is not so bad if correct period bounds is used. Probably the problem still persist if you are in need for big period numbers ... so no useful backtest will be made with mt5.

It seems the same thing with live trading, for this particular strategy there is a need to have 124 bars, and then your set period is bigger it does not work.

https://image.prntscr.com/image/rkmnAhtETmmZTiHXSli7Hg.png

Post's attachments

13 AUDUSD 30 default.xml 12.86 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

8 (edited by Irmantas 2017-12-04 10:43:59)

Re: "Critical runtime error 502 ..." mt5 tester

Hi again,

I got a fix for that nonsense smile So happy to announce it. Hope it will work for all strategies, not just few that I tested. Was wandering why only me was stuck with this error, answer is - because nobody changes strategies parameters after exporting them! And I am changing all parameters for all exported EAs. Almost all EAs works from default settings after exporting from FSBpro no matter how big period is set. But problem arises if you export with some smaller period than you intend to use with mt5/mt4! These max bounds somehow builds in mql code.

Fix: export your strategy with max period set (200), at least in one indicator period! After that use whatever smaller period you want to use with mt4/mt5. And that "array out of range" stops smile

Sleytus be aware of your fix!! It stops error, but starts to produce zeros, and it can be very dangerous if it happens with exit indicator, so your strategies keeps entering, but no exit is activated. If zeros comes to entry signal, you just end without trades...

Also keep in mind, that "shift" calculates into needed period too! Example: let's say you export with 10 period and 100 shift, and it is not working with MT's! So you need to change to 200 period max and 0 shift, export strategy again and change to your wanted 10 period and 100 shift in mt4/mt5 smile Now it works.

Hope it solves a lot frustration for future users smile And maybe some eye opener to Povop why some people experience these kind of errors if they starts to optimize with mt5 or get this error by using shifting

Re: "Critical runtime error 502 ..." mt5 tester

Good detective work...

I'm trying to understand the fix.  Where would I set a max period to 200?

Re: "Critical runtime error 502 ..." mt5 tester

sleytus wrote:

Good detective work...

I'm trying to understand the fix.  Where would I set a max period to 200?

In fsbpro indicator settings period field before exporting to mql file. After exporting you can set lower period values on mt's.

Re: "Critical runtime error 502 ..." mt5 tester

I have another suggested fix...

Search for the method "ActionTrade::FindBarsCountNeeded() and change the line:
    int minBars = MathMax(minDataBars, 50);
to
    int minBars = MathMax(minDataBars, 200);

I am not really setup to test this -- I know it compiles and runs.  But whether or not it fixes the problem you've reported I can't be sure.  At least this is a better fix than the one I mentioned earlier.  Perhaps Popov or footon could have a closer look.

Re: "Critical runtime error 502 ..." mt5 tester

Also, Irmantas, this might be relevant to Portfolio Maker.

alamehmazen123 and myself had noticed that certain strategies when bundled in a portfolio EA trade less frequently (around 20-30%) than their corresponding twin that runs in its own chart.  When developing Portfolio Maker I had also run into the "array out of range" error and got around that problem using my first fix.  But, as you've reported, that may cause a strategy to stop generating signals -- hence fewer trades, which is not good.

I'm very interested in figuring out how best to solve this problem.   If you are interested, I'll keep working with you on this.

Re: "Critical runtime error 502 ..." mt5 tester

Search for the method "ActionTrade::FindBarsCountNeeded() and change the line:
    int minBars = MathMax(minDataBars, 50);
to
    int minBars = MathMax(minDataBars, 200);

It worked ! Let's say this your fix is easier for people who knows how to edit mql code, and my fix to export 200 period max EA is easier for people who does not know that big_smile

I guess that this stuff creates problems with not exact number of trades. Let's say you have strategy with fixed SL, TP or close&reverse, and one indicator for quicker exit point. Your first fix code produced zeros for that exit point, so it will not be active, and now it forced to exits only by fixed SL, TP, or reverse signal. So there definitely will be differences in trade number after some sample!

If your second fix does not creates other problem I would say let's apply it to ALL EA's smile

Re: "Critical runtime error 502 ..." mt5 tester

Excellent -- that is very good news.  I will apply the change to Portfolio Maker.

Thank you, Irmantas.

Re: "Critical runtime error 502 ..." mt5 tester

Thank you too Sleytus for cooperation! Happy that this error is at last solved, it was starting to make me very angry ... big_smile it is hard to find good looking bar opening strategies, which works with multiple data sets, and  after that this shitty error destroys it without good reason ...

Re: "Critical runtime error 502 ..." mt5 tester

Ohhh Thank you, Thank you Thank you!

I have been plagued by this for a long time.

daveM

My 'secret' goal is to push EA Studio until I can net 3000 pips per day....