volume limit unmatched data errors

 

I am getting a lot of errors in the report and no trades entered

2009.09.04 12:46:25 TestGenerator: unmatched data error (volume limit 1528 at 2009.08.17 01:00 exceeded)


Any ideas what's wrong?

#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#include <WinUser32.mqh>
#include <stderror.mqh>
#include <stdlib.mqh>

//////////////////////////////////////////////////////////////////////////////////////
// ERROR LOGGING
//////////////////////////////////////////////////////////////////////////////////////
void logError(string functionName, string msg, int errorCode = -1)
  {
    Print("ERROR: in " + functionName + "()");
    Print("ERROR: " + msg );
    
    int err = GetLastError();
    if(errorCode != -1) 
        err = errorCode;
        
    if(err != ERR_NO_ERROR) 
      {
        Print("ERROR: code=" + err + " - " + ErrorDescription( err ));
      }    
  }

int start()
{

   //does not work on any timeframe other than 5min
   if (Period() != PERIOD_M5) {
      return;
   }
   
   // does not work on holidays.
   if(DayOfWeek()==0 || DayOfWeek()==6) return(0);

   //Trading variables
   int EA_ID = 2;
   double Lotsize = 1;
   double TradeTargetPrice = 15;
   double TradeStopLoss = 15;
   double Devs = 2.9; //2.9% standard deviation for bollinger bands
   int ADXValue = 20; //price must be less than this  
   double BandsDiffVar = 0.0020; //bands must be this distance apart 
   
   //5 decimal systems like Alpari
   if (Point==0.00001)
   {
      TradeTargetPrice=TradeTargetPrice*10;
      TradeStopLoss=TradeStopLoss*10;
   }

   //if any orders with magic ID 2 exist then don't create any new pending ones
   int total = OrdersTotal();
   for(int i=total-1;i>=0;i--) 
   {
         OrderSelect(i, SELECT_BY_POS);
         if ( OrderMagicNumber() == EA_ID ) return;
   }
   
   double LongSL = Ask-(TradeStopLoss*Point);
   double LongTP = Ask+(TradeTargetPrice*Point);
   double ShortSL = Bid+(TradeStopLoss*Point);
   double ShortTP = Bid-(TradeTargetPrice*Point);
   double BandsDiff = iBands(NULL,PERIOD_M5,20,Devs,0,PRICE_CLOSE,MODE_UPPER,0) - iBands(NULL,PERIOD_M5,20,Devs,0,PRICE_CLOSE,MODE_LOWER,0);
   
   if (
         //price touches top 2.9% bolly
         (Bid >= iBands(NULL,PERIOD_M5,20,Devs,0,PRICE_CLOSE,MODE_UPPER,0))
         //ADX < 25
         && (iADX(NULL,PERIOD_M5,14,PRICE_CLOSE,MODE_MAIN,0) < ADXValue)
         //Bollyrange >20
         && (BandsDiff > BandsDiffVar)
      )
      {
         //LONG
         RefreshRates();
         bool ticket=OrderSend(Symbol(),OP_SELL,Lotsize,Bid,NULL,ShortSL,ShortTP,"LONG",EA_ID,0,Green);
      
         if(!ticket)
            {
               int errorCode = GetLastError();
               if(errorCode != ERR_NO_RESULT ) 
                  logError("OrderSend", "Error", errorCode);
            }
         else {Sleep(18000000);} //30mins to wait before re-entering any other trades
      }
      
   if (
         //price touches bottom 2.9% bolly
         (Bid <= iBands(NULL,PERIOD_M5,20,Devs,0,PRICE_CLOSE,MODE_LOWER,0))
         //ADX < 25
         && (iADX(NULL,PERIOD_M5,14,PRICE_CLOSE,MODE_MAIN,0) < ADXValue)
         //Bollyrange >20
         && (BandsDiff > BandsDiffVar)         
      )
      {
         //LONG
         RefreshRates();
         ticket=OrderSend(Symbol(),OP_BUY,Lotsize,Ask,NULL,LongSL,LongTP,"LONG",EA_ID,0,Green);
      
         if(!ticket)
            {
               errorCode = GetLastError();
               if(errorCode != ERR_NO_RESULT ) 
                  logError("OrderSend", "Error", errorCode);
            }
         else {Sleep(18000000);} //30mins to wait before re-entering any other trades
      }

}//end program 


 

Check your data first. Make sure it comes from the same source.

Sounds like the data from various time periods are conflicting.

For example, if the High for M30 happens to be higher than the High for that day etc etc.


CB

 
cloudbreaker:

Check your data first. Make sure it comes from the same source.

Sounds like the data from various time periods are conflicting.

For example, if the High for M30 happens to be higher than the High for that day etc etc.


CB

I thought the strategy tester loaded it automatically?

Can I reset the data?

Also, it seems the sleep function is not working well.

 

Tools|History Center is where you want to look.

If you are online, then the history center will get populated from your broker feed.

However, many prefer (for obvious reasons) to import data from a trusted source and leave the strategy tester offline (for consistent testing).

You could write a book about the number of operational, data, spread etc etc etc variables which one needs to take into account in order to understand the context of a particular test run (some of these variables varying when you don't want them to, others when they downright shouldn't and yet others not varying when you'd like them to).

Can of worms. Horrible slimy worms, at that. Not your honest upstanding earthworm.


CB

 

Ok - sorted now, had to select Period M5

The sleep function doesn't seem to be working here, it is entering mutiple trades at the same time.

...and a lot of OrderSend 130 errors.

 
The sleep function doesn't seem to be working here, it is entering mutiple trades right after each other.
 

Just selecting M5 is not clearing up the fact that there is still unmatched data in the history center. You're just turning away from it.

Sleep() is ignored by strategy tester.

Error 130 (invalid stops) much documented on this forum.


CB

 
.....
 
FinGeR:
.....

sleep is ignored? ANy other suggestions on how to test this then? Would I have to add some sort of time flag?

Do I have to delete everything in the history centre?

I thought it wa sinvalid stops but the stop is 15pips away so can't be that. More likely it's the entry point...or not?

 
SanMiguel:

sleep is ignored? ANy other suggestions on how to test this then? Would I have to add some sort of time flag?

Do I have to delete everything in the history centre?

I thought it wa sinvalid stops but the stop is 15pips away so can't be that. More likely it's the entry point...or not?


Here you'll find info about what is ignored in the tester. Amongst other things. There are other posts in the forum on ways to get around limitations such as this. You just need to search.

'Testing Features and Limits in MetaTrader 4'


What you need to do regarding the history center depends upon how you need to use it. You could for example:

- Import all data from a reputable source (plenty on this here and in other forums)

- Import M1 data from a reputable source and use the period_converter script (included with the platform) to manufacture the longer time periods

Up to you. Have a look through the plentiful information on strategy tester on this site.


Its a stops problem. Period. Could be you're too close. Check MarketInfo(Symbol(),MODE_STOPLEVEL). If this returns zero, then you need to create the order without stops and subsequently modify. If it returns a value, then you need to be that number of pips away (in the correct direction) from your entry price. You should also check that you have normalized your stops to the correct number of decimal places. Lastly - just to reiterate that stops values when used as parameters in the trading functions are absolute prices - not relative numbers of pips. Sorry, but I've seen folks try all sorts. :-)


CB

Reason: