Download MetaTrader 5

Using OnCalculate

To add comments, please log in or register
Are you accustomed to using the standard library? MQL5 has one!
LukeB
140
LukeB 2016.01.25 03:56 

Please find attached an indicator that does nothing but display the values passed to OnCalculate - and a few other values from functions common in indicator development.

Question:  Why, when accessing  volume[] or spread[] do I get an  'index out of range error'?  Are these values not supported in all instances of MQL4?  I'm using FXCM demo account to test, with version 4, build 950.

Keith Watford
Moderator
9599
Keith Watford 2016.01.26 04:13  

When you get an arrayout of range error, the error report will tell you in which line of your code that the error occurs.

Please paste that line and block of code here 

Zirkon
122
Zirkon 2016.01.26 17:32  
LukeB:

Please find attached an indicator that does nothing but display the values passed to OnCalculate - and a few other values from functions common in indicator development.

Question:  Why, when accessing  volume[] or spread[] do I get an  'index out of range error'?  Are these values not supported in all instances of MQL4?  I'm using FXCM demo account to test, with version 4, build 950.

 

Not supported (filled) by MT4. It's for compatibility with MT5.
LukeB
140
LukeB 2016.01.28 02:15  
GumRai:

When you get an arrayout of range error, the error report will tell you in which line of your code that the error occurs.

Please paste that line and block of code here 

Pretty sure zirkoner's answer is correct.  The lines that produce the errors are commented out in the code supplied, they have = volume[0]; and = spread[0];.  comment the =0; substitutes out, un-comment these and the program crashes.
To add comments, please log in or register