problem in testing program with strategy tester

Back to topics list To post a new topic, please log in or register
avatar
2
meysam 2015.11.21 21:25
 

To whom it may be concern

I have successfully compiled my program without any error and I had results when I have checked my Program with Strategy tester until last week. But todays I have NO results! (No buy or sell signals) and also No error while I testing the program with EURUSD 5MIN charts.

Could you help me please to understand what the problem is?


void OnTick()

  {

  static datetime Old_Time;

   datetime New_Time[1];

   bool IsNewBar=false;

   int copied=CopyTime(_Symbol,_Period,0,1,New_Time);

   if(copied>0) 

     {

      if(Old_Time!=New_Time[0]) 

        {

         IsNewBar=true;  

         Print("We have new bar here ",New_Time[0]," old time was ",Old_Time);

         Old_Time=New_Time[0];            

        }

     }

   else

     {

      Alert("Error in copying historical times data, error =",GetLastError());

      ResetLastError();

      return;

     }

   if(IsNewBar==false)

     {

      return;

     }

   int Mybars=Bars(_Symbol,_Period);

   if(Mybars<60) 

     {

      Alert("We have less than 60 bars, EA will now exit!!");

      return;

     }



     MqlTick latest_price;      

     MqlRates mrate[];          

   ArraySetAsSeries(mrate,true);

   if(!SymbolInfoTick(_Symbol,latest_price))

     {

      Alert("Error getting the latest price quote - error:",GetLastError(),"!!");

      return;

     }

   if(CopyRates(_Symbol,_Period,0,3,mrate)<0)

     {

      Alert("Error copying rates/history data - error:",GetLastError(),"!!");

      ResetLastError();

      return;

      }

    cciHandle1=iCCI(_Symbol,_Period,CCI_Period,PRICE_CLOSE,0);

   cciHandle2=iCCI(_Symbol,_Period,CCI_Period,PRICE_CLOSE,1);

   bool Sell_Condition_1=(cciHandle1<100);

   bool Sell_Condition_2 = (100<cciHandle2); 

    int total=OrdersTotal();

    int ticket;

     //--- Putting all together   

   if((Sell_Condition_1)&&(Sell_Condition_2)) 

    {

       if(total!=0)

          {

            Alert("We already have a open Position!!!");

            return;    // Don't open a new sell Position

           }

      ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,1,Bid+STP*_Point,Bid-TKP*_Point,NULL,EA_Magic,0,clrNONE);

          if (ticket<0)

            { 

           Print("orderSend failed with error#",GetLastError());

          RefreshRates();

           return;

             }

           else

            sellcond1=true;

             Print("we have a sell order");

         }

        

   bool Buy_Condition_1=(sellcond1);

   buycond1=false;

   if(Buy_Condition_1)

     if (cciHandle1<-100)

      {

         buycond1=true;

             bool result=false;

             if (buycond1==true)  

                if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)

             {

              result=OrderClose(OrderTicket(),Lot,Ask,0,Red);

              return;

             }

       }               

  }

 

   

avatar
12985
WHRoeder 2015.11.22 14:24 #
 
meysam: But todays I have NO results! (No buy or sell signals) and also No error while I testing
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. datetime New_Time[1];
    bool IsNewBar=false;
    int copied=CopyTime(_Symbol,_Period,0,1,New_Time);
    Why use complicated functions, when you could use the predefined variable Time[1]?

  3. int Mybars=Bars(_Symbol,_Period);
    Why use complicated functions, when you could use the predefined variable Bars?
  4. cciHandle1=iCCI(_Symbol,_Period,CCI_Period,PRICE_CLOSE,0);
    cciHandle2=iCCI(_Symbol,_Period,CCI_Period,PRICE_CLOSE,1);
    Don't use misleading variable names. iCCI returns a double value not a handle.
  5. ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,1,Bid+STP*_Point,Bid-TKP*_Point,NULL,EA_Magic,0,clrNONE);
    You buy at the Ask, sell at the Bid. Your stops should be relative to appropriate line. NULL is not a valid string; use ""

  6. int total=OrdersTotal();
    if(total!=0)
    This makes your EA incompatible with every other including itself on other charts and manual trading. Use an OrderSelect loop filtered by magic number and pair to count orders.

    if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)
    Same.
  7. result=OrderClose(OrderTicket(),Lot,Ask,0,Red);
    return;

  8. Add print statements before your tests and print out the variable values and find out why.
avatar
15
dark_voyager 2015.11.22 19:43 #
 

WHRoeder,

I think meysam's problem is a more general problem with the Strategy Tester in recent builds of MT4.

I say this because I posted a question on Nov 6th entitled "Problem using Strategy Tester in Build 902" to which I received no replies.  Here it is again:


"

Hi,

I'm going to quote a message from luxorlo about Build 902 that was posted on October 22nd:

"

 I wrote a message in the 890 version section but I this has been deleted so I write here again the issue I have detected in build 890 hoping that this will be fixed in this new version, if not be aware of that because it's an important issue:

After build 890 was developed, the start up process with a file ( terminal.exe fili.ini) does not work because the terminal can't detect the expert advisor you are trying to use. Detect symbol, spread, model and dates, but not the ea. If you put the ea manually in the platform and launch again the process (closing the platform before of course) the genetic process does not work showing all results with 0 balance although the variables are changed as marked in the setup file (this can be watch in the optimization results in column inputs). 

 Could you please check it and fix this problem?

 We all be very grateful as it's an option that most of us use to increase the speed of our work."



Well, 15 days have passed since then, but I'm still finding the same problem with Build 902.  When you try to test an EA in the Strategy Tester, all the results have 0 balance and no trades are opened!  The EA I'm testing is a simple, straightforward one that compiled perfectly and ran correctly in the Strategy Tester in Builds prior to 890.

Are other people finding this problem too?

Can MetaQuotes please resolve it as soon as possible.

Thank you.

~DV
avatar
2
meysam 2015.11.29 11:29 #
 

dear WHRoeder

thanks for your answer.

my problem is solved.

good luck 

Back to topics list  

To add comments, please log in or register