Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
bchip
11
bchip 2016.07.05 16:52 

Hi everyone


First post here, however reading a lot. 

Hoping someone here can help with this.  Im struggling quite a bit with the strategy tester.

Im not really sure what Im doing wrong as I watched a video code this EA and it showed results.

Are there any limitations to the strategy tester that I should be aware of? Like you cant use the Hour() function or something.

Ive google around but cant find anything on it.


The system is simply, @ 9am Open a new long position,  40 pips target, 40 pips stop & only take the first order. (if theres anything in the code thats wrong)

Why does this produce no backtesting results?

Any help on this would be appreciated.

extern int StartHour = 9;
extern double Lots = 1.0;
extern int TakeProft = 40;
extern int StopLoss = 40;

void OnTimer()
  {
 static bool isFirstTick = true;
 static double ticket = 0;
 
 if (Hour() == StartHour) {
   if (isFirstTick == true) {
           isFirstTick = false;
           
           ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 10, Bid-StopLoss*Point, Bid+TakeProft*Point, "Buy at Time System");
           if (ticket<0){
             Print("Error Opening Order.");
           }
   }
 } else {
         isFirstTick = false;
         
 }//if Hour
  }
whroeder1
13600
whroeder1 2016.07.05 18:12  
bchip: Why does this produce no backtesting results?
void OnTimer()
  1. Because the timer doesn't work on the tester.
    In backtest OnTimer() not performs (M. Ali) - MQL4 forum
    Chart Event For MT4 Backtester (Migel) - MQL4 forum
  2. Why are you using a repeating timer, instead of OnTick?
bchip
11
bchip 2016.07.05 20:09  

Hi

Thanks for the quick response.

I changed to OnTick and it made no difference to the results.


Do note that if I change the code to

//if (Hour() == StartHour) {

 if (true) {


So it does run, I do get a result of 1 trade.

Keith Watford
Moderator
7887
Keith Watford 2016.07.06 05:32  
 if (Hour() == StartHour) {
 ///////
 } else {
         isFirstTick = false;
         
 }//if Hour

isFirstTick is set to false if Hour()!=StartHour

bchip
11
bchip 2016.07.06 06:11  
GumRai:

isFirstTick is set to false if Hour()!=StartHour



Oh! I think I understand what your saying,

the first run is at hour = 0, sets it as false and then it stays false continuously.

Will have to rethink the code a bit when I get a chance.


Thank you!

/
To add comments, please log in or register