1 (edited by Hannes 2016-12-19 04:17:41)

Topic: "Array out of range"

As soon as I attach the following EA to a chart, it removes it instantaneously.

Screenshot: http://imgur.com/a/QFjj1

The log file says the following:

0    00:47:00.586    MaxMillion USDJPY USDJPY,H1: MaxMillion USDJPY loaded.
0    00:47:00.598    MaxMillion USDJPY USDJPY,H1: Loading data: USDJPY,H1, Minumum bars: 202...
1    00:47:00.599    MaxMillion USDJPY USDJPY,H1: array out of range in 'MaxMillion USDJPY.mq4' (1672,22)
3    00:47:00.599    MaxMillion USDJPY USDJPY,H1: not initialized
0    00:47:00.599    MaxMillion USDJPY USDJPY,H1: uninit reason 8
0    00:47:00.603    Expert MaxMillion USDJPY USDJPY,H1: removed
0    00:48:34.270    Expert MaxMillion USDJPY USDJPY,H1: loaded successfully

The following line causes the Exception (left loop in just for context):

for (int bar = 0; bar < firstBar; bar++)
        indComp.Value[bar] = 0; //this one

Could anyone help me? It would be quite the pain to look into it myself, as I have no idea how FSB structures its EAs code wise.

Post's attachments

MaxMillion USDJPY.mq4 351.49 kb, 10 downloads since 2016-12-19 

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

Re: "Array out of range"

Thank you for the report.

This bug is fixed in FSB Pro v 3.8.1 with EA Code v41.

Please update FSB Pro (you can download the installer and run over your previous installation) and re-export the EA.

The core of the problem is wrong firstBar calculation in the "Average True Range" indicator.

You can also fix the bug manually in your EA:

Change line 2746 from

   int firstBar=period+period+2;

to

   int firstBar=period+previous+2;

Re: "Array out of range"

Thank you very much Popov.

Re: "Array out of range"

Hello Popov and Team! smile
Same error when trying to load the EA into the trade demo account.
Image 1.
We have a similar problem in the following strategy (FSB 3.8.2.0, version 46.0 code):
In Zip file are all files (images, xml, mql4, ex4, and log).
I checked the lines code cited by Popov and were already correct (lines 2538, 2973, 3239, 3574).
I also loaded a good amount of bars in the graph to force the history (as Image 2).
I believe there is something else causing the same error.
Very grateful if you can check.

The other EAs are working correctly, even loading a minimum amount of pre-bars between 100 and 200.
Thanks in advance for the great tools!

Regards,
Samuel.

Post's attachments

Strategy.zip 794.69 kb, 11 downloads since 2017-10-22 

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

Re: "Array out of range"

Samuel, update your FSB to 3.8.4, everything works fine on my end. I'll check it when market opens later as well.

Re: "Array out of range"

Thank you very much footon for your quick reply.
Can you load the Strategy in open market now?
Can you or somebody rebuild mql4 and mql5 files for me? Because my license expired some days before update.
Very grateful if you can check and rebuild.

Regards,
Samuel.

Re: "Array out of range"

Yes, everything works well, no errors.

Re: "Array out of range"

I am having this exact same problem. I too am getting the "array out of range" error. Similar to the OP, the offending line of code is...

indCompLong.Value[bar]=0;

Here is the generated code around this.

void Indicator::OscillatorLogic(int firstBar,int previous,const double &adIndValue[],double levelLong,
                                double levelShort,IndicatorComp &indCompLong,IndicatorComp &indCompShort,
                                IndicatorLogic indLogic)
  {
   double sigma=Sigma();
   firstBar=MathMax(firstBar,2);

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

   switch(indLogic)
     {
      // etc.
     }
   }

Is this a bug, or is this something I can fix?