Download MetaTrader 5

TestGenerator: unmatched data error - page 2

To add comments, please log in or register
Ernest Klokow
1112
Ernest Klokow  
ubzen:
You're right my oversight.


That's ok! I do the same thing all the time!

My log file tells me that when running the system it never goes beyond / past the following line of code:

dSellPrice = iHigh(NULL,0,4)- (PipsOpenTrans * UsePoint);

After going through the "for" loop (only once?? Should it not first complete the loop?) it goes back to the first declaration, which is:

double HighestLevel = iHigh(NULL,0,5);

It then just keeps on looping endlessly the same way. NEVER computing the next major "if" statement - EVEN IF IT IS TRUE!

if (nBarHighNo > nBarLowNo)
Ernest Klokow
1112
Ernest Klokow  

I think I have found something!

The NBarHighNo can be less than 4 (even as low as 1) so when the "for" loop starts going the counter (for (int i = nBarHighNo; i >= nBarHighNo - 4; i--)) can be reduced to a minus value, i.e i = -1,-2, or -3.

That means we will have the following situation e.g. High[-3], which does not make sense, because that is looking into the future!

What do you think? Is this the problem? And if so how do we solve it?

Ubzen
5394
Ubzen  
I'm happy that you're making progress. Again debugging is not my strong suit and giving that I'm clearly having an off-day, the best recommendation I can give right now is. If that segment of code is giving you a hard time, try re-programming the same logic from scratch. I have a few things I wanna complete myself so keep plowing away.
whroeder1
15326
whroeder1  
double HighestLevel = iHigh(NULL,0,5);
int nBarHighNo = iHighest(NULL,0,MODE_HIGH,5,1);
iHigh(NULL,0,5)==High[5] the high of 5 bars ago. If you want the highest high of the last 5 bars you need
int    nBarHighNo   = iHighest(NULL,0,MODE_HIGH,5,1);
double HighestLevel = High[nBarHighNo]; // or iHigh(NULL,0,nBarHighNo);
Ernest Klokow
1112
Ernest Klokow  
WHRoeder:
iHigh(NULL,0,5)==High[5] the high of 5 bars ago. If you want the highest high of the last 5 bars you need

Thanks again WHRoeder for pointing out my mistake with the HighestLevel variable. I personally would never have picked it up since I am still new to MQL4 programming and its many standard functions. I wish I had your knowledge and expertise, but I am sure that it also came through years of applying yourself and learning by experience. Not sure how I can ever repay you for your kind deeds, but I am sure the universe will see to it that you get your reward.

I have changed the code a bit to avoid the counter i from going into the negative, but I am not sure if the logic is correct.

Here is the code:

         double HighestLevel;
         int nBarHighNo;
         double LowestLevel;
         int nBarLowNo;
                
         while(nBarHighNo != 5 || nBarLowNo != 5)
         break;   
            {           
               i++;
               nBarHighNo = iHighest(NULL,0,MODE_HIGH,5,1);
               HighestLevel = High[nBarHighNo];
               nBarLowNo = iLowest(NULL,0,MODE_LOW,5,1);
               LowestLevel = Low[nBarLowNo];
            }
                 
         if (nBarHighNo == 5)
            {
               for (i = 4; i >= 1; i--)
               RefreshRates();
                  if (High[i-1] < HighestLevel)
                     {
                        if (Close[i-1] <= Open[i])
                        
                        {
                           nBullRevBars = nBullRevBars + 1;
                           dSellPrice = iHigh(NULL,0,4)- (PipsOpenTrans * UsePoint);
                        } 
                        else nBullRevBars = nBullRevBars + 0;
                     }
                    else 
                     {
                        nBullRevBars = 0;
                        dSellPrice = 0.0;
                     }
              }
Ernest Klokow
1112
Ernest Klokow  

At last the Strategy Tester are running now, but I am experiencing the following strange problems:

1. The High[] array has no prices. Returns 0 for every instance.

2. The Close[] array similarly does not have any values. All read = 0

3. The Open[] has got values/prices.

Because Close[] has no value (=0), but Open[] do have values, the expression

if (Close[i-1] <= Open[i])

will ALWAYS be true - therefore the loop!

So if i can solve the mystery why the arrays High[] and Close[] have no values I think the riddle will be solved and the algorithm should work!

whroeder1
15326
whroeder1  
 while(nBarHighNo != 5 || nBarLowNo != 5)
         break;   
            {           
               i++;
               nBarHighNo = iHighest(NULL,0,MODE_HIGH,5,1);

the while and break could be commented out leaving just the bracketed code. i++ isn't used there and isn't initialized

If the highest high isn't bar 5 what are those variables and what happens next?

Ernest Klokow
1112
Ernest Klokow  
WHRoeder:

the while and break could be commented out leaving just the bracketed code. i++ isn't used there and isn't initialized

If the highest high isn't bar 5 what are those variables and what happens next?

William, I sent some information as requested by private message to you.

(By the way my second name is also William!)

partha
16
partha  

Usually, this error occurs when data in the MT4 chart history doesn't match between different time-frames. So, if a M1 bar high is 133.58 and M15 bar that contains this M1 bar has high at 133.56, the unmatched data error will be displayed. Try deleting history of that currency and reloading it. 

whroeder1
15326
whroeder1  
Partha:
  1. This thread is three and 1/2 years old. Don't dredge up old posts without good reason.
  2. The unmatched problem was answered in the first two replies and the thread moved on.
12
To add comments, please log in or register