Download MetaTrader 5

Problems ob Backtesting

To add comments, please log in or register
amando
434
amando  

Hello,

 

i haven an code, which is running every day one.

this is working propper, but on an backtest, it always running 2 times

 

code:

 

int OnInit()
  {

// initialisieren der EMA's
   MAHandle20= iMA(_Symbol,PERIOD_D1,Trail_EMA,0,MODE_EMA,PRICE_CLOSE);
   MAHandle50= iMA(_Symbol,PERIOD_D1,Main_EMA,0,MODE_EMA,PRICE_CLOSE);
   MAHandle150=iMA(_Symbol,PERIOD_H1,SL_EMA,0,MODE_EMA,PRICE_CLOSE);

// in welcher Häufigkeit (Sekunden) das Event vorkommen soll
   EventSetTimer(60);

   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {//--- destroy timer
   EventKillTimer();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   if(Hour()==Start1 && Minute()==Minute)

 

as Hour() i use as exempla 10 which means 10:00 and as minute i use 0

on Live trading this code working, only on backtesting this will run at 10:00 and 10:01

 

2015.01.29 19:31:35.821 2014.01.27 07:01:00   buy stop 0.10 EURUSD at 1.37114 sl: 1.36264 (1.36823 / 1.36832 / 1.36823)

2015.01.29 19:31:35.821 2014.01.27 07:01:00   order canceled [#7 buy stop 0.10 EURUSD at 1.37114]

2015.01.29 19:31:35.821 2014.01.27 07:01:00   Ticketnummer: 1

2015.01.29 19:31:35.821 2014.01.27 07:01:00   EURUSD LS_Trendfilter - EMA50_0: 1.36331 - EMA50_1: 1.36311 - EMA direction: EMA_Long - Kerzen: Kerzen Long

2015.01.29 19:31:35.821 2014.01.27 07:00:00   buy stop 0.10 EURUSD at 1.37114 sl: 1.36264 (1.36824 / 1.36833 / 1.36824)

 

i always was thinking, the code will run one time from the top to the botton, but i registerd, that on backtesting it runs 2 times

 

any ideas?

 

amando 


Alain Verleyen
Moderator
32434
Alain Verleyen  
amando:

Hello,

 

i haven an code, which is running every day one.

this is working propper, but on an backtest, it always running 2 times

 

code:

 

 

as Hour() i use as exempla 10 which means 10:00 and as minute i use 0

on Live trading this code working, only on backtesting this will run at 10:00 and 10:01

 

2015.01.29 19:31:35.821 2014.01.27 07:01:00   buy stop 0.10 EURUSD at 1.37114 sl: 1.36264 (1.36823 / 1.36832 / 1.36823)

2015.01.29 19:31:35.821 2014.01.27 07:01:00   order canceled [#7 buy stop 0.10 EURUSD at 1.37114]

2015.01.29 19:31:35.821 2014.01.27 07:01:00   Ticketnummer: 1

2015.01.29 19:31:35.821 2014.01.27 07:01:00   EURUSD LS_Trendfilter - EMA50_0: 1.36331 - EMA50_1: 1.36311 - EMA direction: EMA_Long - Kerzen: Kerzen Long

2015.01.29 19:31:35.821 2014.01.27 07:00:00   buy stop 0.10 EURUSD at 1.37114 sl: 1.36264 (1.36824 / 1.36833 / 1.36824)

 

i always was thinking, the code will run one time from the top to the botton, but i registerd, that on backtesting it runs 2 times

 

any ideas?

 

amando 


What is Hour() and Minute() functions, there is no such function with mql5.
amando
434
amando  
angevoyageur:
What is Hour() and Minute() functions, there is no such function with mql5.

right, i use time conversation from mql4, comes direct from an include

 

 

int Hour()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.hour);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int DayOfWeek()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.day_of_week);
  }
//+------------------------------------------------------------------+
int TimeDayOfWeek(datetime date)
  {
   MqlDateTime tm;
   TimeToStruct(date,tm);
   return(tm.day_of_week);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int Minute()
  {
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.min);
  }
amando
434
amando  

is there any idea?

 

amando 

To add comments, please log in or register