1 (edited by vlad123 2015-03-13 08:40:24)

Topic: Array out of range error in exported MQ4 EA


At first - great progress with FSB! Its functionality, even in free mode - very impressive!

But I faced with an issue - I exported FSB strategy to MQ4, but when I'm trying to attach it to the MetaTrader chart - it writes "Array out of range" in expert's log and disappears from chart.

Line and position numbers points to the method "void HMA::Calculate(DataSet &dataSet)", line "Component[1].Value[bar]=tempVal;". Error occurs accessing "Value[bar]".

I've inserted some debug lines before this line, and here are some details:
- Accessing Component[1], ArraySize(Component)=10
- Assigning Component[1].Value[4], ArraySize(Component[1].Value)=0

I found that there are two lines in the original HMA.cs:
                Component = new IndicatorComp[2];
                Component[1] = new IndicatorComp {Value = new double[Bars]};
but there is nothing similar/corresponding in generated MQ4.

Any idea - how to fix this?
In general - generated MQ4 doesn't look as one-to-one replica of initial CS, so I'm afraid to make manual changes to MQ4.

Re: Array out of range error in exported MQ4 EA

Can you attach the strategy and/or expert?

You have to not change the expert. The issue can be in an indicator code or something other.
We cannot do anything to fix it without the strategy.

Re: Array out of range error in exported MQ4 EA

I've just prepared a simple strategy with HMA and generated MQ4.
FSB strategy, generated MQ4 and HMA.cs are in attached archive.

Post's attachments

Archive.zip 41.87 kb, 3 downloads since 2015-03-13 

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

Re: Array out of range error in exported MQ4 EA

There was a problem in the MQL code of HMA indicator - Component[1] was not initialized.
You can download the fixed version from the repository: HMA: Hull Moving Average

Place it in C:\Program Files\Forex Strategy Builder Pro\User Files\MT4 Files\MQL\Forexsb.com\Custom folder and export your expert again.


There is some problem when the indicator is download from the program's Indicator Repository page. I'll try to fix it soon. Use the web Repository for now.

Thank you for the report.

Re: Array out of range error in exported MQ4 EA

I found the problem with the repo.

When MQL code is updated in the repo, it has different file ID. However, FSB Pro updates the indicator indexes every 24 hours. If your index was updated recently and someone update the mql code of an indicator, the program will try to download the old file ID and actually will download an error html page sad .
It can be fixed by reloading the indicator's index.


Re: Array out of range error in exported MQ4 EA

Great, thank you!

I've re-loaded Indicators' index, then HMA itself, and then re-generated MQL4 EA - and now it works (or at least - was placed on the chart) OK.