REGARDING BACKTESTING AND OPTIMIZATION

 

Hi ,

I hope someone can shed some light regarding the issues that i facing right now .

I found out i have the different result if using backtesting and optimization 

here the result manually backtesting and edit parameter 

100


200 


300


400

500

meanwhile if iam using optimization have this result


optimization


here my code 

//TEST
#property strict

extern int entry_level=300;

extern int top_profit=150;
extern int stop_loss=300;


bool trade;


double price_b=0;
double price_b_top=0;
double price_b_low=0;

double  price_top=0;
double   price_bottom=0;

//ONTICK
void OnTick()
  {

//DRAW OBJECT ON MONDAY
   if(DayOfWeek()==1)
      if(Hour()==3)
        {

         price_b=((High[2]-Low[2])/2)+Low[2];
         price_b_top=price_b+(entry_level*Point);

         //B REFER BASE
         ObjectCreate(PERIOD_CURRENT,"BASE_LINE",OBJ_HLINE,0,TimeCurrent(),price_b);
         ObjectSetInteger(PERIOD_CURRENT,"BASE_LINE",OBJPROP_WIDTH,2);
         ObjectSetInteger(PERIOD_CURRENT,"BASE_LINE",OBJPROP_COLOR,clrYellow);

         //T REFER TOP
         ObjectCreate(PERIOD_CURRENT,"TOP",OBJ_HLINE,0,TimeCurrent(),price_b_top);
         ObjectSetInteger(PERIOD_CURRENT,"TOP",OBJPROP_WIDTH,2);
         ObjectSetInteger(PERIOD_CURRENT,"TOP",OBJPROP_COLOR,clrBlue);

        }
//open trade
   if(DayOfWeek()==1)
      if(Hour()>=3 && Hour()<=20)
        {
         //price line above
         price_top=ObjectGetDouble(PERIOD_CURRENT,"TOP",OBJPROP_PRICE,0);


         if(Low[0]>price_top)
            if(OrdersTotal()==0)
               if(totalDailyTrade()==0)
                 {
                  trade=OrderSend(Symbol(),OP_SELL,AccountBalance()*0.0001,Bid,30,Bid+(stop_loss*Point),Bid-(top_profit*Point),"null",1001,NULL,clrRed);
                 }

        }





   if(Hour()==23)
     {
      ObjectDelete(PERIOD_CURRENT,"BASE_LINE");
      ObjectDelete(PERIOD_CURRENT,"TOP");

      price_top=0;
      price_b_top=0;

     }



//this slow backtesing
   if(DayOfWeek()==1)
     {
      for(int i=10 ; i>=0 ; i--)
        {
         Comment(
            "DAY= "+(string)DayOfWeek(),
            "\n"
            "ENTRIES LEVEL = "+(string)entry_level,
            "\n"
            "PRICE ="+(string)price_b_top,
            "\n"
            "OBJ GET PRICE="+(string)price_top
         );
        }
     }






  }//END


//control trade
int totalDailyTrade()
  {
   int tt=0;
   for(int i=0; i<=OrdersHistoryTotal() ; i++)
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
         if(TimeDayOfYear(OrderOpenTime()) == TimeDayOfYear(TimeCurrent()))
           {
            tt++;
           }
   return tt;
  }
//+------------------------------------------------------------------+


As shown result above backtesting and optimization have the different result .

Does this mean my code are problem ? Or MT4 problem? Or Iam missing something here . Hope someone can help me with this issues 


regards

Cosmas.

 

alright guys , now i know why i get this such result and here the reason 

reason

Reason: