Ea works in DEMO trading , But Strategy tester does not

 

I have a Ea which I can run in our Demo account and it buys and sells with NO issues.

when I try to run it in the Stategy Tester, The chart shows " Waiting for Update", next message, "MetaTrader has stopped working".

I have checked :

1/Mt4 "IS not in Program files", So NOT UAC issue.

2/ The .ex4 and Mq4 files are in experts and when I compile both update as expected.

3/Other Ea's work in strategy tester

4/I deleted some of the Alerts and Print statements.

5/EA is NOT running on the Terminal at the same time I am trying to run it in strategy tester.

After taking these steps, still it doesn't work in strategy tester, Does anyone have any suggestions that may assist.

Thanks

 
barnacle7:

I have a Ea which I can run in our Demo account and it buys and sells with NO issues.

when I try to run it in the Stategy Tester, The chart shows " Waiting for Update", next message, "MetaTrader has stopped working".

I have checked :

1/Mt4 "IS not in Program files", So NOT UAC issue.

2/ The .ex4 and Mq4 files are in experts and when I compile both update as expected.

3/Other Ea's work in strategy tester

4/I deleted some of the Alerts and Print statements.

5/EA is NOT running on the Terminal at the same time I am trying to run it in strategy tester.

You didn't check the one thing you needed to, do you have data for the date range you are trying to test ? for example, lets take the whole of 2011 on EURUSD as an example, to check if you have this data open a M1 EURUSD chart, zoom out and press the PgUp key to scroll left until you reach the start of 2011, if you can't get there then you do not have the required data to test with in the Strategy Tester.
 

RaptorUK:
You didn't check the one thing you needed to, do you have data for the date range you are trying to test ? for example, lets take the whole of 2011 on EURUSD as an example, to check if you have this data open a M1 EURUSD chart, zoom out and press the PgUp key to scroll left until you reach the start of 2011, if you can't get there then you do not have the required data to test with in the Strategy Tester.

With M1 (EURUSD) it goes back to 31st May 2013.

With H1 (EURUSD) goes back to 11 Feb 2003.

I can see that the M1 data does not go back to 2011,however,

I am trying to do my backtest on (EURUSD) on the 1hr chart for the Period 1st May 2013 to 25th May 2013.

It is able to do the Strategy backtest on other EAs using the same period and timeframe of 1Hr.

Is this still the reason causing the issue ? any other suggestions .

Thanks

 
barnacle7:

With M1 (EURUSD) it goes back to 31st May 2013.

With H1 (EURUSD) goes back to 11 Feb 2003.

I can see that the M1 data does not go back to 2011,however,

I am trying to do my backtest on (EURUSD) on the 1hr chart for the Period 1st May 2013 to 25th May 2013.

It is able to do the Strategy backtest on other EAs using the same period and timeframe of 1Hr.

Is this still the reason causing the issue ? any other suggestions .

Thanks

You have data back to 31st May so you cannot start your test on the 1st May as you do not have data for that date . . . start your test on a later date or get more data.
 
barnacle7:

I have a Ea which I can run in our Demo account and it buys and sells with NO issues.

when I try to run it in the Stategy Tester, The chart shows " Waiting for Update", next message, "MetaTrader has stopped working".

You have an EA that does NOT return from start?
 

"when I try to run it in the Stategy Tester, The chart shows " Waiting for Update", next message, "MetaTrader has stopped working"."

This can happen when your hard-drive is nearly full. When you do a lot of testing that results in repetitive error messages it can use up a lot of your hard-drive space.

Delete all logs that you no longer need

 
GumRai:

"when I try to run it in the Stategy Tester, The chart shows " Waiting for Update", next message, "MetaTrader has stopped working"."

This can happen when your hard-drive is nearly full. When you do a lot of testing that results in repetitive error messages it can use up a lot of your hard-drive space.

Delete all logs that you no longer need

 

I tried to run it in strategy tester again in June but still had the same issue.

I copied all the code from the EA that wasn't working in Strategy tester and created a New Ea blank page with a different name and pasted all the code to it (A new .mq4 file).

It now works in Strategy tester, in either May or June.

I still don't know what caused the issue ?, but now it is working in strategy tester.

Thanks all for your input.

 

Hello,

I have the same problem. EA on Demo works perfectly, but on strategy tester no results or just one.

First of all I got alert in journal:

Ok. Maybe problem in history data. Then entering wrong passwords I disconnected from both accounts (Demo and real), closed chart, deleted all .hst files from /MT4/history/Demo and /MT4/history/Live folders (in ..../Live folder left 4 files: symbols.raw, symbols.sel, symgroups.raw and ticks.raw). Downloaded new M1 data, Imported it to MT4, then converted to others periods with built-in "period-converter" script.

Then launched tester again (still disconnected from accounts). No data errors left:

But results the same...

When importing M1 data to MT4 I don't know what mean this:

I tried import data with checked and unchecked this tick. Results a little bit changed each time, but absolutely not how they must look in real.

Of course there are more question which I need to find out. For example I imported data to MT4 with checked "volume" tick. And tried to test may EA in short period (from 2013 oct. 01 to 2013 oct.30). tester opened some orders from 17.oct to 25 oct. But when I changed testing period (without changing any other inputs) from earlier date to same 2013 oct.30 tester opened only one order. Very interesting :) But this example is not a problem so far. Real problem is - WHY TESTING IS NOT WORKING GENERALLY? Maybe problem is in code?

If I described my problems not very clearly or not enough of explanation - please tell me and I will try to specify.

I'd be very grateful for any suggestions and comments.

P.S. sorry for my english...


There it is code. And please do not laugh on my programing skills :)


//+------------------------------------------------------------------+
//| Common variables                                                 |
//+------------------------------------------------------------------+
   extern double Lots=0.01;                     
   extern int    Slipage=2;                     
   extern int    GMTshift=0;                    
   
   double H3,H4,H5;
   double L3,L4,L5;
   
   double D3=0.2750;
   double D4=0.55;

   int ticket;
   int magic=69969;
   
   string symb;
   string order_comment="my_EA";
       
   bool open_crit=true;
  
   
   
  
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

  //--------shift time, high, low, close.
  
  int shifted_time=(TimeCurrent()-GMTshift*3600);                           //shifted time
  int shifted_cur_day=TimeDayOfWeek(shifted_time);                          //shifted day of week
  int shifted_cur_hour=TimeHour(shifted_time);                              //shifted hour
  
  double prev_high=High[iHighest(NULL,PERIOD_H1,MODE_HIGH,24,(shifted_cur_hour+1))];          //prev day highest price
  double prev_low=Low[iLowest(NULL,PERIOD_H1,MODE_LOW,24,shifted_cur_hour+1)];                //prev day lowest price
  double prev_close=iClose(NULL,PERIOD_H1,shifted_cur_hour+1);                                //prev day close price
    
  //camarilla levels
  
  double H5pre = (prev_high/prev_low)*prev_close;
  double H4pre = ((prev_high - prev_low)* D4) + prev_close;
  double H3pre = ((prev_high - prev_low)* D3) + prev_close;
  double L3pre = prev_close - ((prev_high - prev_low)*(D3));
  double L4pre = prev_close - ((prev_high - prev_low)*(D4));
  double L5pre = prev_close - (H5pre - prev_close);
  
  //normalizing doubles
  
  H5=NormalizeDouble(H5pre,Digits);
  H4=NormalizeDouble(H4pre,Digits);
  H3=NormalizeDouble(H3pre,Digits);  
  L3=NormalizeDouble(L3pre,Digits);
  L4=NormalizeDouble(L4pre,Digits);
  L5=NormalizeDouble(L5pre,Digits);
  
  
 //---------------define criteria "open_crit". It is mean that if no opened orders in this GMT shifted day - criteria is "true".
 //---------------and new order can be opened 
    
   symb=Symbol();                                                  // Security name
   

    for(int j=1; j<=OrdersTotal(); j++)                             // Loop through orders
      {
       if (OrderSelect(j-1,SELECT_BY_POS)==true)                    // If there is the next one
         {
         if(OrderSymbol()!=symb)continue;                          // Another security, continue
       
         int opn_time_a=TimeDayOfWeek(OrderOpenTime()-GMTshift*3600); //orders opening day
         
           if(opn_time_a==shifted_cur_day)                        //if orders opening day same as curent day...
             {
               open_crit=false;                                     //criterion is false
               //Alert("STOP, today opened order found");         
               break;                                               // and get out of cycle
             }
             else                                                   
             {
               open_crit=true;                                     
               //Alert("Go on, no todays orders");
             }
         }
       }  
 
 // opening BUY order 
 
    if(Ask==L3&&open_crit==true)
      {
        RefreshRates();
        Alert("Opening BUY. Waiting for server confirmation...");
        ticket=OrderSend(symb,OP_BUY,Lots,Ask,Slipage,L4,H3,order_comment,magic);            // pirkimo orderio atidarymas
        if(ticket>0)
          {
            Alert("Done ",ticket);
          }
          else
          {
            Alert(GetLastError());
          }
       }
 
       
  return;                                       //exit start
  }
 
margiliauskas:

Hello,

I have the same problem. EA on Demo works perfectly, but on strategy tester no results or just one.

First of all I got alert in journal:

Ok. Maybe problem in history data. Then entering wrong passwords I disconnected from both accounts (Demo and real), closed chart, deleted all .hst files from /MT4/history/Demo and /MT4/history/Live folders (in ..../Live folder left 4 files: symbols.raw, symbols.sel, symgroups.raw and ticks.raw).


If you disconnect from your Broker and delete all your symbol information how do you expect your EA to work correctly ?
 
RaptorUK:
If you disconnect from your Broker and delete all your symbol information how do you expect your EA to work correctly ?


I not deleted these files. Deleted only .hst. I don't know what these files are, so I left them in folder. And now I'am not fully understand: delete these files and disconnect from broker before starting testing?

Thanks

Reason: