Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 590
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
Hello!
Can you please show me how an EA based on Triple Exponential Average indicator can be prohibitedto open a position if the last trade is taken out by SL?
MQL5
I have no problems with it in normal mode, but as soon as I start optimisation the error prints at each run and there is no output.
But the thing is, it doesn't even execute the code. I've put Prints around the program, no output, just an error on every run that exits.
Why is the Print not working?
MQL5
The Expert Advisor works without problems in normal mode, but as soon as I start optimizing it, it complains on every pass that it has entered the array limits.
But the thing is, it doesn't even execute the code. I've put Prints around the program, no output, just an error on every run that exits.
Why doesn't Print work?
You have to check the array size. You are shown a line where there is an output outside the array. Here, you must insert Print before this line, in which you write the output of the array size and index, by which you are trying to access array data - the array size and index will be printed in the log, and then the program will exit with an error.
BUT! Do all this in the tester in visual mode, not in optimizer - in optimizer (and tester in non-visual mode) all printers are disabled for acceleration.
Exit outside the array before reaching Print().
Check the size of the array. You are shown a line where the output is outside the array. Before this line, you must insert Print, in which you write the output of the array size and index, by which you are trying to access array data - the array size and index will be printed into the journal, and then the program will crash.
BUT! Do it all in the tester in visual mode, not the optimizer - in the optimizer (and the tester in non-visual mode) printers are all off for acceleration.
That is the problem, everything works with any parameters in the visual, but with any optimization it goes out of bounds
That's the problem that with any parameters in the visual all works, but with any optimization it is out of bounds
What is there in the array? I can only guess that either there is no data in the array yet, or it is smaller than you think. Are there any checks in the program for the array size?
What is in the array? I can only guess that either there's no data in the array yet, or it's smaller than you think. Are there any checks in the program for the size of the array?
Last N, I have 500, macd values, and cycle limits are strictly limited and can never be less than 0 and greater than N, I've both debugged it and counted on paper
The last N, I have 500, macd values, and the loop limits are strictly limited and can never be less than 0 and greater than N, I've both debugged it and counted it on paper
Are you sure the array is full of data when you access it? Is there a check for data availability and that the array has the right value?
Just because it's written and calculated on a piece of paper doesn't mean it matches what the EA received (didn't receive).
Are you sure that the array is full of data when you access it? Is there a check that the data is available and that the array has the right size?
Just because it's written and calculated on a piece of paper doesn't mean it matches what the Expert Advisor received (didn't receive).
Yes, at the beginning, before all operations, it is copied from the buffer.
Yes, at the beginning, before all operations, copied from the buffer
Copied. And how much is copied is checked?
If you are using an indicator with smoothing, it requires a few more bars than you expect. Therefore, just because you have copied does not mean that the data has been copied and is available in its full size.
It is easier for you to check the size of the array and, if it does not have the required size, exit OnTick()