Here is the output:
2010.08.17 16:32:11 TestLines EURUSD_fx,M1: , Line_0: 0.00000other dim: 2.00000, Line_1: 0.00000other dim: 0.00000 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 0 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: here: 2 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 30 = 1.27069 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 29 = 1.27331 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 28 = 1.27331 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 27 = 1.27553 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 26 = 1.28038 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 25 = 1.28185 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 24 = 1.28242 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 23 = 1.28669 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 22 = 1.28706 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 21 = 1.28731 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 20 = 1.28731 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 19 = 1.28754 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 18 = 1.28763 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 17 = 1.28763 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 16 = 1.28763 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 15 = 1.28763 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 14 = 1.28763 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 13 = 1.28764 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 12 = 1.28813 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 11 = 1.28815 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 10 = 1.28817 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 9 = 1.28817 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 8 = 1.28817 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 7 = 1.29009 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 6 = 1.29154 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 5 = 1.29154 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 4 = 1.29301 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 3 = 1.29785 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 2 = 1.30336 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 1 = 1.30417 2010.08.17 16:32:11 TestLines EURUSD_fx,M1: Line Table 0 = 1.33342
I was curious about that, but isn't "ArrayResize(FrequencyArray, 1);" supposed to increment the first dimension? I followed some sample code I found (more than one) and they initiated the code in the same way and incremented the array size like I am doing. Not that I disagree with you, I am just trying to understand the right way to do it and why their way was wrong. They seemed to have a much heavier use for the arrays than what I am doing, it should be fairly simple.
You are correct, ArrayResize will resize the first dimension. But in your case, the problem lies with the second dimension which only has 1 element and you reference it with FrequencyArray[xyz_variable][0]..............FrequencyArray[xyz_variable][1] does not exist.
Just thought I would give my opinion. MT4 help says
I think MT4 wants you to use dimension 2 and above for things that you know the size of but use dimesion 1 for how many there are so you can vary that count. Since MT4 doesn't handle arrays properly I always stick to single dimension arrays. |
if (IsFound == false) // Not found, bump up counter and add price value { ArrayResize(FrequencyArray, 1);
If it's not found, you reset the size back to one instead of increasing the array size.
if (LineArray[i] == FrequencyArray[x][i])
You're comparing to [x][i] instead of [x][1]
Also, think about whither you should be comparing two doubles with == versus approximately equal.
Simplified code:
for (i = 0; i <= ArraySize(LineArray); i++){ // Loop through LineArray one price value at a time FreqArySize = ArraySize(FrequencyArray); for (int x = 0; x <= FreqArySize; x++){ //Loop through frequencyarray to see if price value exists bump up counter if (x == FreqArySize){ ArrayResize(FrequencyArray, x+1); FrequencyArray[x][0] = 1; FrequencyArray[x][1] = LineArray[i]; break; } if (LineArray[i] == FrequencyArray[x][1]){ FrequencyArray[x][0] += 1; break; } } }
Just thought I would give my opinion. MT4 help says
I think MT4 wants you to use dimension 2 and above for things that you know the size of but use dimesion 1 for how many there are so you can vary that count. Since MT4 doesn't handle arrays properly I always stick to single dimension arrays. |
What do you mean MT4 doesn't handle arrays properly? How so? What should I look out for?
You are correct, ArrayResize will resize the first dimension. But in your case, the problem lies with the second dimension which only has 1 element and you reference it with FrequencyArray[xyz_variable][0]..............FrequencyArray[xyz_variable][1] does not exist.
The second value is the column sizing, which MQL does not allow you to change the number of columns only the number of rows. The first value is the number of rows which is what I want to resize anyway. The declaration of [][1] means that I want 2 columns but at the moment no rows.
So the first thing I do in the dual for loop is to increase the rows and then add the data. This way, I am only increasing the needed number of rows as I have data to enter.
I believe that by example where I got the code from this part is correct.
If it's not found, you reset the size back to one instead of increasing the array size.
You're comparing to [x][i] instead of [x][1]
Also, think about whither you should be comparing two doubles with == versus approximately equal.
Simplified code:
I think you might have it here. I will copy your code here and test it. I will get back and let you guys know if it solved the problem. Thank you all for your help.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have this array of 31 price values. I want to compare them to a new array FrequencyArray[][1] where I store the count of how frequent a particular price appears in the list of 31 price values and their price value itself. So we will use LineArray[] as the mass list and do a lookup on FrequencyArray to see if the price exists, if it does, then we just bump up the number in that arrayth location, if it does not exist, we add it and bump the arrayth location holding the count for the new price value.
Here is the code:
I will respond to this thread with the results so you can see what I am working with. Problem is that I am not getting the data of LineArray into the FrequencyArray and I am not sure what I am doing wrong.