Why error "strategy tester report not found"

 

Hi, in the following code why is it on market test when i tested once it passed okay

But when i try again about 30 minutes later with the exact same code it says "test on EURUSD H1 strategy tester not found" 

#property copyright "Copyright 2023, Stephen J Reynolds"
#property link      "https://www.intraday-trading-tools.com"
#property version   "1.00"
#property strict

input double LotSize = 1.0;

// Global variables
int gBuyTicket;

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   //+------------------------------------------------------------------+
   // Test Buy Order     (NOTE : Basing sltp on Ask for buystop matters. It didnt pass once as i based sltp on bid when i changed to ask it passed)
   //+------------------------------------------------------------------+
   double priceAsk=Ask+(1000*_Point);
   double priceBid=Bid+(1000*_Point);
   double SL=NormalizeDouble(priceAsk-(50*_Point),_Digits);
   double TP=NormalizeDouble(priceAsk+(50*_Point),_Digits);
   int hr = Hour();
   
   // Test Order
   if(hr>=0)      
   {
      static int buyTicket = 0;
      static int count = 0;
      static datetime timeCu; 
      datetime timePr = timeCu; 
      timeCu=Time[0];    // To count seconds change Time[0] to Seconds();  
      bool isNewBa = timeCu != timePr;
      
      if(isNewBa) count++;

      // Open Order
      if(count==1 && isNewBa) //  && isNewBa
      {
         if(!CheckMoneyForTrade(Symbol(),LotSize,OP_BUY)) return;    
         if(!CheckVolumeValue(LotSize)) return;
         if(!CheckStopLoss_Takeprofit(OP_BUYSTOP,priceAsk,SL,TP)) return;
         
         gBuyTicket=OrderSend(Symbol(),OP_BUYSTOP,LotSize,priceAsk,30,SL,TP);
      }

      // Close Order
      if(count==2 && isNewBa) // && isNewBa
      { 
         bool select = OrderSelect(gBuyTicket,SELECT_BY_TICKET);
         
         if(OrderType() == OP_BUYSTOP)
         {                 
            bool close = OrderDelete(gBuyTicket,clrGreen);
            gBuyTicket = 0;
         }
      }    
   } 
  }


//+------------------------------------------------------------------+
//| CheckMoneyForTrade()                                             |
//+------------------------------------------------------------------+
bool CheckMoneyForTrade(string symb, double lots,int type)     
{
   double free_margin=AccountFreeMarginCheck(symb,type,lots); 
   //-- if there is not enough money
   if(free_margin<0)
   {
      string oper=(type==OP_BUY)? "Buy":"Sell";
      Print("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError());
      return(false);
   }
   //--- checking successful
   return(true);
}
  
//+------------------------------------------------------------------+
//| Check the correctness of the order volume                        |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume)
{
//--- minimal allowed volume for trade operations
   double min_volume=MarketInfo(Symbol(),MODE_MINLOT);
   if(volume<min_volume)
   {
      Print("Volume is less than the minimal allowed. Minimum allowed is ",min_volume);
      return(false); // If womeone types lower than minimum lotvolume it returns print
   }

//--- maximal allowed volume of trade operations
   double max_volume=MarketInfo(Symbol(),MODE_MAXLOT);
   if(volume>max_volume)
   {
      Print("Volume is greater than the maximal allowed. Maximum allowed is ",max_volume);
      return(false);
   }

//--- get minimal step of volume changing
   double volume_step=MarketInfo(Symbol(),MODE_LOTSTEP);

   int ratio=(int)MathRound(volume/volume_step);
   if(MathAbs(ratio*volume_step-volume)>0.0000001)
   {
      PrintFormat("Volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f",
                               volume_step,ratio*volume_step);
      return(false);
   }
   Print("Correct volume value");
   return(true);
}   
 
//+------------------------------------------------------------------+
// Check Proper Stop Loss Take Profit Levels
//+------------------------------------------------------------------+ 
bool CheckStopLoss_Takeprofit(ENUM_ORDER_TYPE type,double price,double SL,double TP)
{
//--- get the SYMBOL_TRADE_STOPS_LEVEL level
   int stops_level=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);
   if(stops_level!=0)
   {
      PrintFormat("SYMBOL_TRADE_STOPS_LEVEL=%d: StopLoss and TakeProfit must"+
                  " not be nearer than %d points from the closing price",stops_level,stops_level);
   }
     
   bool SL_check=false,TP_check=false;
  
//--- check only two order types
   switch(type)
   {
      //--- Buy operation
      case OP_BUY:
      {
         //--- check the StopLoss
         SL_check=(price-SL>stops_level*_Point);
         if(!SL_check)
            PrintFormat("For order %s   StopLoss=%.5f must be less than %.5f"+
                        " (Bid=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),SL,Bid-stops_level*_Point,Bid,stops_level);
         //--- check the TakeProfit
         TP_check=(TP==0.0 || ((TP-price)>stops_level*_Point));
         Print(" TP = ",TP," TP_check = ",TP_check);
         if(!TP_check)
            PrintFormat("For order %s   TakeProfit=%.5f must be greater than %.5f"+
                        " (Bid=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),TP,Bid+stops_level*_Point,Bid,stops_level);
         //--- return the result of checking
         return(SL_check&&TP_check);
      }
      //--- Sell operation
      case OP_SELL:
      {
         //--- check the StopLoss
         SL_check=(SL-price>stops_level*_Point);
         if(!SL_check)
            PrintFormat("For order %s   StopLoss=%.5f must be greater than %.5f"+
                        " (Ask=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),SL,Ask+stops_level*_Point,Ask,stops_level);
         //--- check the TakeProfit
         TP_check=(TP==0.0 || ((price-TP)>stops_level*_Point));
         if(!TP_check)
            PrintFormat("For order %s   TakeProfit=%.5f must be less than %.5f"+
                        " (Ask=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),TP,Ask-stops_level*_Point,Ask,stops_level);
         //--- return the result of checking
         return(TP_check&&SL_check);
      }
      //--- BuyStop pending order
      case OP_BUYSTOP:
        {
         //--- check the StopLoss
         SL_check=((price-SL)>stops_level*_Point);
         if(!SL_check)
            PrintFormat("For order %s   StopLoss=%.5f must be less than %.5f"+
                        " (Open-StopLoss=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),SL,price-stops_level*_Point,(int)((price-SL)/_Point),stops_level);
         //--- check the TakeProfit
         TP_check=((TP-price)>stops_level*_Point);
         if(!TP_check)
            PrintFormat("For order %s   TakeProfit=%.5f must be greater than %.5f"+
                        " (TakeProfit-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),TP,price-stops_level*_Point,(int)((TP-price)/_Point),stops_level);
         //--- return the result of checking
         return(SL_check&&TP_check);
        }
      //--- SellStop pending order
      case OP_SELLSTOP:
        {
         //--- check the StopLoss
         SL_check=((SL-price)>stops_level*_Point);
         if(!SL_check)
            PrintFormat("For order %s   StopLoss=%.5f must be greater than %.5f"+
                        " (StopLoss-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),SL,price+stops_level*_Point,(int)((SL-price)/_Point),stops_level);
         //--- check the TakeProfit
         TP_check=((price-TP)>stops_level*_Point);
         if(!TP_check)
            PrintFormat("For order %s   TakeProfit=%.5f must be less than %.5f"+
                        " (Open-TakeProfit=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
                        EnumToString(type),TP,price-stops_level*_Point,(int)((price-TP)/_Point),stops_level);
         //--- return the result of checking
         return(TP_check&&SL_check);
        }
      break;     
   }
//--- a slightly different function is required for pending orders
   return false;
}

Thanks for any help on this matter

Files:
 
Hello, you solved this? I have same problem.
 
Stephen Reynolds:

Hi, in the following code why is it on market test when i tested once it passed okay

But when i try again about 30 minutes later with the exact same code it says "test on EURUSD H1 strategy tester not found" 

Thanks for any help on this matter

where is OnInit() function?

 
Igor Pereira Calil #:
Hello, you solved this? I have same problem.

1- check if your code has OnInit() function

2- check if you checked for min balance inside of that function.

 
The error was corrected, it worked to update the MT4 product.