I think you have declared 2 arrays with zero elements . .
Try this . .
double HVal[10],LVal[10]; // Storage for Day High/Low
I think you have declared 2 arrays with zero elements . .
Try this . .
Many thanks. Probably my mistake that I still haven't been known how many elements are required for HVal[] and LVal[]. I'm going to try it soon.
BTW, may I ask if I have to code the arrays being dynamic (unfixed no of elements), how could I use a variable to define these two arrays HVal[] and LVal[]? I think I have tried to define a variable like k and then put k into the two arrays to become HVal[k], LVal[k] but I remembered that I've got error (forgot what error though). Any ideas to accomplish this without errors?
There are a few Functions available to handle arrays: https://docs.mql4.com/array
Define with a fixed size, then if you need to make the Arry bigger you can use ArrayResize . . . be a little careful, you might need to SetAsSeries first . . there is info in the Book about Arrays that will probably help : https://book.mql4.com//
bool ResizeBuffer(double& buffer[], int size){ if (ArraySize(buffer) != size){ ArraySetAsSeries(buffer, false); // Shift values B[2]=B[1]; B[1]=B[0] if (ArrayResize(buffer, size) <= 0){ trading.disabled = "ArrayResize [1] failed: "+GetLastError() + " Trading disabled."; Alert(trading.disabled); Print(trading.disabled); return(false); } ArraySetAsSeries(buffer, true); } return(true); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I've found out that one of my EAs cannot put High[] and Low[] values into an assigned variable which is also a double typed array.
I've taken out that coding and rewrote a very simple program to test it again with the source code as follows:
Any ideas from your experiences? I've already reinstalled MT4 software. From the alert message, I could only see the following:
High[0]=88.64,HVal[0]=0,Low[0]=88.59,LVal[0]=0
Regards,