Download MetaTrader 5
To add comments, please log in or register
1000 developers are involved in Freelance service activity. Sign up!
dennisj2
153
dennisj2 2015.08.04 18:17 

Don't know if it's my broker, but, this should not be possible. I am getting an array out of range exception when attempting to access Close[0] - Don't mind the issue per se, but, the lack of ability to trap the exception so that the EA doesn't crash is not acceptable. Thought maybe it would happen on a bar change - not. This occurs so frequently - 1-2 time per day - that I don't have any trust in my EA. Anyway, here are the snippets. Any help would be greatly appreciated.


Log:

2015.08.04 10:56:30.663 array out of range in 'PipRegression.mqh' (213,77)


Line 213:

    if (fabs(Pip(NormalizeDouble(pipHistory[0],Digits)-NormalizeDouble(Close[0],Digits)))>=1.0)
whroeder1
13641
whroeder1 2015.08.04 19:24  
dennisj2: I am getting an array out of range exception when attempting to access Close[0] - D
 if (fabs(Pip(NormalizeDouble(pipHistory[0],Digits)-NormalizeDouble(Close[0],Digits)))>=1.0)
  1. You assume that it's the Close[0] and not the pipHistory[0]. Find out which
    double c = Close[0];
    double h = pipHistory[0];
     if (fabs(Pip(h)-c))>=1.0)
  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
dennisj2
153
dennisj2 2015.08.04 20:04  
WHRoeder:
  1. You assume that it's the Close[0] and not the pipHistory[0]. Find out which
  2. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong


Regarding the assumption that it might be piphistory[0] - the error specifically points to the array access at column 77 - which is the Close  [0] -

                                                                                                                                                                                                    ^ = 77

I haven't found any issues with normalize double - I've used this for years and found that this is the only consistent way to compare doubles - I've had to correct code where floating .00000001's and the like caused my equality checks to fail - some of these errors were very recent prompting me to use normalizedouble everywhere I performed equality checks. I'm surprised to hear that there or opponents to its use - I remember a ways back when I asked this forum about double equality checks and was told that normalizedouble should always be used.

That said, piphistory is a class CArrayDouble - if the error was piphistory, then the exception would have (should have) been thrown in the class code - which it is not.

MQL4 is by far the best forex code available on the market today - but, the fact that it chooses to crash an EA without having the capability to trap and correct the exception is a very weak facet.

thanks for tips - I'll have to explore normalizedouble in more depth. I implemented the code snippet you suggested and will wait for the next exception to be thrown.

whroeder1
13641
whroeder1 2015.08.05 11:12  
dennisj2: I've used this for years and found that this is the only consistent way to compare doubles - I've had to correct code where floating .00000001's and the like caused my equality checks to fail - some of these errors were very recent prompting me to use normalizedouble everywhere I performed equality checks.
Obviously didn't follow the links provided.
dennisj2
153
dennisj2 2015.08.05 11:57  
WHRoeder:
dennisj2: I've used this for years and found that this is the only consistent way to compare doubles - I've had to correct code where floating .00000001's and the like caused my equality checks to fail - some of these errors were very recent prompting me to use normalizedouble everywhere I performed equality checks.
Obviously didn't follow the links provided.
yeah, obviously. Still doesn't address the Close[0] array exception - which should never, ever happen.
dennisj2
153
dennisj2 2015.08.07 11:15  
dennisj2:
yeah, obviously. Still doesn't address the Close[0] array exception - which should never, ever happen.


Well, it happened again. How do you catch an array issue of this type? Clearly, Close[0] must be commonly used. As a side note, this issue only appears to be happening on the GBPUSD pair -- I've been running other pairs quite successfully without issue. I'm thinking this may be an issue with my broker - but, that said - this still should not happen ever. Could I possibly report this as a bug?

Error:

2015.08.07 03:20:34.698 array out of range in 'PipRegression.mqh' (213,21)

Code:

208 //+------------------------------------------------------------------+
209 //| CalcMA - Morphs the global CalcMA to calc on pip history         |
210 //+------------------------------------------------------------------+
211 void CPipRegression::CalcMA(void)
212   {
213     double c = Close[0];
214     double h = pipHistory[0];
215     
216     if (NormalizeDouble(fabs(Pip(h-c)),Digits)>=1.0)
217     {
/
To add comments, please log in or register