Nightcrawler: What am I doing wrong ?
- Look in the log. You will see that your code crashed and why.
- Next time, use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
William Roeder:
Thank you for your fast reply and thank you very much for pointing out the debugger, I was unware of its existance. I've tried to use it but all I can see is the journal saying "loaded successfully" then "removed", with no messages whatsoever in the debug tab. I've also tried to "Comment()" the value of _LastError, but nothing comes out. I guess for now I'll just try to learn more about the debugger. Thanks!
- Look in the log. You will see that your code crashed and why.
- Next time, use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
- Look in the Experts tab.
- Set breakpoints before running the debugger.
William Roeder:
Thank you once again, I was able to get the error. There is an array out of range error. I've found endless material on different reasons why this error is showing, I'm only to figure out why in my code. Thanks for these useful pointers!
- Look in the Experts tab.
- Set breakpoints before running the debugger.
In case anybody struggles, I was able to fix my "out of range" error by simply setting getting the bars count and resizing the array to this value:
int IBARS = iBars(Symbol(), Period()); if(ArraySize(testVar) < IBARS) { ArrayResize(testVar, IBARS); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Greetings,
I've recently started learning MQL, and I have stumbled upon this issue. I'm looping the total num of bars and trying to assign a value to an array. The problem is that the array seems to remain empty even though I assign a value to it. Here's an example:
I'm expecting the Comment at the end to say "The value of the first element is: 1", but instead the comment never shows. If I instead remove testVar from the comment then I can see it working. It is simply not assigning a value to this array. What am I doing wrong ?