Very strange behaviour

Back to topics list To post a new topic, please log in or register
avatar
83
BeLikeWater 2015.01.03 15:03
 

Dear MQL4 users.

Im "in shock" I cant understand the behaviour of my EA when backtesting, maybe you could help me a little bit.

I look at indicators in different timeframes, here is what I use:

bool Long_Ready()
   {
      if(iMA(Symbol(),30,200,0,1,0,1)<Close[0])
         if(iMA(Symbol(),5,200,0,1,0,1)<Close[0])
            if(iRSI(Symbol(),30,14,0,1)>50)
               if(iRSI(Symbol(),5,2,0,2)<20)
                 if(iRSI(Symbol(),5,2,0,1)>20) 
                   return true;
       return false;
   }


The strange behaviour came in Backtesting in timeframes that are not m5. I follow the reading of the indicators above using "Comments" as you can see here:

      Comment("EMA M30 (200) = ",DoubleToStr((iMA(Symbol(),30,200,0,1,0,1)),5),"\n","EMA M5 (200) = ",DoubleToStr((iMA(Symbol(),5,200,0,1,0,1)),5),"\n","RSI M30 (14) = ",DoubleToStr((iRSI(Symbol(),30,14,0,1)),1),"\n","RSI M5 (2) = ",DoubleToStr((iRSI(Symbol(),5,2,0,1)),1));


The behaviour that I not understand in that at the beginning of the backtesting, for example in H1 the EA cannot access any of the indicators value, as the backtesting progress (Im using tick by tick) the EA can access the m30 indicators values, and then at the end of the backtesting (last 3/4) it can access the m5 values and the EA starts functioning normally... I cannot understand what is happening, could you help me?

Also If I backtest on m5 everything goes fine.

Greetings

BeLikewater

avatar
13009
WHRoeder 2015.01.04 16:40 #
 
BeLikeWater:

I look at indicators in different timeframes, here is what I use:

The strange behaviour came in Backtesting in timeframes that are not m5. I follow the reading of the indicators above using "Comments" as you can see here:

The behaviour that I not understand in that at the beginning of the backtesting, for example in H1 the EA cannot access any of the indicators value, as the backtesting progress (Im using tick by tick) the EA can access the m30 indicators values, and then at the end of the backtesting (last 3/4) it can access the m5 values and the EA starts functioning normally...
  1. Your code
     Simplified
    bool Long_Ready()
       {
          if(iMA(Symbol(),30,200,0,1,0,1)<Close[0])
             if(iMA(Symbol(),5,200,0,1,0,1)<Close[0])
                if(iRSI(Symbol(),30,14,0,1)>50)
                   if(iRSI(Symbol(),5,2,0,2)<20)
                     if(iRSI(Symbol(),5,2,0,1)>20) 
                       return true;
           return false;
       }
    bool Long_Ready(){
       return  iMA(NULL,PERIOD_M30,200,0,MODE_EMA,PRICE_CLOSE,1) < Bid
           &&  iMA(NULL,PERIOD_M5, 200,0,MODE_EMA,PRICE_CLOSE,1) < Bid
           && iRSI(NULL,PERIOD_M30, 14,           PRICE_CLOSE,1) > 50
           && iRSI(NULL,PERIOD_M5,   2,           PRICE_CLOSE,2) < 20
           && iRSI(NULL,PERIOD_M5,   2,           PRICE_CLOSE,1) > 20;
    }
    Don't hard code numbers - write self documenting code.
  2. We can't see here because you didn't post the output.
  3. Prior to build 600, if you have sufficient history before test start date the tester generated up to 1000 bars. Otherwise the tester only generates 100 bars and moves start of test forward. This may no longer be true or broken for other timeframes. Print out period and iBars(period) and iTime(period,0) for 0, 30, and 5 and find out what's changed.
Back to topics list  

To add comments, please log in or register