Need to understand how backtester works

 

I'm testing a new expert I've developed.

What I don't understand is why are results in backtest absolutely different if I backtest it in 1M or in 1H?

I thought that when backtesting 1H charts, backtester uses History of 1M, 5M, 15M, 30M and 1H. And that the most detailed history file is, always, 1M history file. So if you backtest your ea in 5M and you have downloaded 1M history, your backtest will actually use 1M history.

So, according to this, if I've downloaded history of all timeframes, everytime I run the backtest it should be the same (except for the spread of that moment), no matter the timeframe I'm running it, if in my code I'm not referring anywhere to the time of the chart... something like

Max = High[iHighest(Symbol(),0,MODE_HIGH,1,0)];

What am I missing?

Here's some of the code of this expert:

  if (Hour() == 19){
    Max = High[iHighest(Symbol(),PERIOD_H1,MODE_HIGH,1,0)];
    Min = Low[iLowest(Symbol(),PERIOD_H1,MODE_LOW,1,0)];
  }
  
  
  if (Hour() >= 20 && Hour() <= 22) { // If between these hours, we can trade
   //We buy and sell here, according to Max and Min values
  }
 
  Max = High[iHighest(Symbol(),PERIOD_H1,MODE_HIGH,1,0)];
  Min = Low[iLowest(Symbol(),PERIOD_H1,MODE_LOW,1,0)];
High[] and Low[] are pointing to the actual timeframes use iHigh, iLow instead
 

Thanks for the answer, but the results are the same.

Here's the full code. As you see, I'm not referring to the timeframe of the local chart for anything, but the results of backtesting in different TF's are different.


Thanks again


int start()
  {
  double myLot = Lot;
  double myTP = TakeProfit;
  double mySL = StopLoss;
  double mySpread = MarketInfo(Symbol(),MODE_SPREAD);
  
  if (Hour() == 19){
   Max = iHigh(Symbol(),PERIOD_H1,0);
   Min = iLow(Symbol(),PERIOD_H1,0);
  }
  
  if (OrdersTotal() == 0) openOrder = false;
  
  if (Hour() >= 20 && Hour() <= 22) { // If between these hours, we can trade
    if (Bid > Max && !openOrder) {     //Buy
      OrderSend(Symbol(),OP_SELL,myLot,Bid,3,Bid+mySL*Point,Min,"Lets Buy",Magic,0,Red);
      openOrder = true;
    }
    if (Ask < Min && !openOrder) {     //Sell
      OrderSend(Symbol(),OP_BUY,myLot,Ask,3,Ask-mySL*Point,Max,"Lets Buy",Magic,0,Green);
      openOrder = true;
    }
  }
   return(0);
  }
 
  Max = iHigh(Symbol(),PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,1,0));

is the equivalent using iHigh

//z

 

Ok, I've changed it again, but... results remains the same.

Here are a couple of screenshots of backtest in 1M and another in 5M:

1M:


5M:

The question is... why?

I'm a bit lost...

 

I'm puzzled too. What I understood was that the Period that you set in the tester is relevant for calculation of the indicators. In your case you have specified PERIOD_H1 for your Max and Min so the selected period should be of no relevance. But what Model are you using? If you're using "Every tick" the results should surely be the same, because start() fires on every tick. It doesn't help that the help files are written by someone who I don't think has the best grasp of English.

Actually I can see it says "Cada tick" on your graphs, so every tick.

 

Thanks for your answer.

I don't want to blame anyone or allegue that the help files are translated wrongly.

I'm sure (well, almost) that there must be some consistent explanation to my question.


I'd like also to apologize for my bad english, and for the errors in the comments in my previous code snippet. The comments are wrong... That's because I had changed the code and not replaced the comments.

 

Hi here is my result with following code:

extern double Lot=0.1;
extern double TakeProfit=100;
extern double StopLoss=100;
  double Max,Min;
  bool openOrder=false;
  int Magic=101;
int start()
  {
  double myLot = Lot;
  double myTP = TakeProfit;
  double mySL = StopLoss;
  double mySpread = MarketInfo(Symbol(),MODE_SPREAD);

  
  if (Hour() == 19){
   Max = iHigh(Symbol(),PERIOD_H1,iHighest(Symbol(),PERIOD_H1,MODE_HIGH,1,0));
   Min = iLow(Symbol(),PERIOD_H1,iLowest(Symbol(),PERIOD_H1,MODE_HIGH,1,0));
  }
  
  if (OrdersTotal() == 0) openOrder = false;
  
  if (Hour() >= 20 && Hour() <= 22) { // If between these hours, we can trade
    if (Bid > Max && !openOrder) {     //Buy
      OrderSend(Symbol(),OP_SELL,myLot,Bid,3,Bid+mySL*Point,Min,"Lets Buy",Magic,0,Red);
      openOrder = true;
    }
    if (Ask < Min && !openOrder) {     //Sell
      OrderSend(Symbol(),OP_BUY,myLot,Ask,3,Ask-mySL*Point,Max,"Lets Buy",Magic,0,Green);
      openOrder = true;
    }
  }
   return(0);
  }

i have tried to complete your code so that it work on tester, i assume you not posted the whole logic. because:

M5:

M1:

 

Here's what I get using your code, zzuegg:


 
Then your history-file is corrupt.. delete all history files download new clean file and rebuild the timeframes...
 
I went "Tools/History Centre" and deleted EURUSDSB. It said "There are no new data for a symbol 'EURUSDSB'. I ran the tests and got the same results as before.
Reason: