Download MetaTrader 5
To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
Amadeusss
51
Amadeusss 2014.09.29 12:04 

 

As you can see, the tester works perfectly well, but when it gets to 2006-11-03 (vertical blue crosshair line) it will stop. No matter what testing dates I select it always stops at that point so I have to do another testing from a few days after all the way to 2014. I never had this problem before and it happens in all five computers, some linux, some windows.

Amadeusss
51
Amadeusss 2014.09.29 12:05  
Amadeusss:


 

As you can see, the tester works perfectly well, but when it gets to 2006-11-03 (vertical blue crosshair line) it will stop. No matter what testing dates I select it always stops at that point so I have to do another testing from a few days after all the way to 2014. I never had this problem before and it happens in all five computers, some linux, some windows.

 

Do you have any clue? 

Simon Gniadkowski
Moderator
17994
Simon Gniadkowski 2014.09.29 12:09  
Amadeusss:


 

As you can see, the tester works perfectly well, but when it gets to 2006-11-03 (vertical blue crosshair line) it will stop. No matter what testing dates I select it always stops at that point so I have to do another testing from a few days after all the way to 2014. I never had this problem before and it happens in all five computers, some linux, some windows.

How big is your .fxt file ?
Carl Schreiber
6395
Carl Schreiber 2014.09.29 12:12  
have you looked in the journal tab, was there a zero-devide?
whroeder1
14242
whroeder1 2014.09.29 12:33  
gooly: have you looked in the journal tab, was there a zero-devide?
FXT file too large, zero divide, or infinite loop - not returning from start/OnInit. (Add a print at start and at the return.)
Amadeusss
51
Amadeusss 2014.10.01 23:07  
RaptorUK:
How big is your .fxt file ?

Thank you Raptor, see, EURUSD1440_0.fxt is 1.7 Gb. Hope that helps.

Forgot to say, it doesn't happen with other EA's. I do not have any date related coding (well, if I did the last operation would not say "close at stop".) 

Amadeusss
51
Amadeusss 2014.10.01 23:25  
gooly:
have you looked in the journal tab, was there a zero-devide?

Thank you gooly. 

2014.10.02 01:18:42.921 EURUSD,Daily: 15115001 tick events (4838 bars, 91811847 bar states) processed within 25310 ms (total time 106717 ms)

2014.10.02 01:18:42.921 2006.11.03 05:37  Tester: order #511 is closed
2014.10.02 01:18:42.919 2006.11.03 00:00  Probando3.03 EURUSD,Daily: modify #511 buy 1.00 EURUSD at 1.27792 sl: 1.27533 tp: 1.31679 ok
2014.10.02 01:18:42.919 2006.11.03 00:00  Probando3.03 EURUSD,Daily: Alert: 511  abierta EURUSD
2014.10.02 01:18:42.919 2006.11.03 00:00  Probando3.03 EURUSD,Daily: open #511 buy 1.00 EURUSD at 1.27792 ok
2014.10.02 01:18:42.909 2006.11.01 16:16  Tester: stop loss #510 at 1.27693 (1.27690 / 1.27712)
2014.10.02 01:18:42.909 2006.11.01 16:04  Probando3.03 EURUSD,Daily: OrderModify error 1
2014.10.02 01:18:42.909 2006.11.01 16:04  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27693 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27692 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27691 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27690 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27689 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27688 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27687 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:03  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27686 tp: 1.31716 ok
2014.10.02 01:18:42.909 2006.11.01 16:02  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27685 tp: 1.31716 ok

2014.10.02 01:18:42.909 2006.11.01 16:02  Probando3.03 EURUSD,Daily: modify #510 buy 1.00 EURUSD at 1.27662 sl: 1.27684 tp: 1.31716 ok

 

I didn't have time to check out a Trailing Stop error that I have, but it doesn't bother the execution of the bot, it just doesn't trail-stop properly. All operations are opened with SL and TP (only one operation can be open at any time), as you can see in the graphic, and in the last operation neither of them is reached on 2006.11.03 05:37 when it is closed  to never open an operation again. You can also see that there are many operations, the circumstances to open operation happen quite often.


Amadeusss
51
Amadeusss 2014.10.01 23:34  
WHRoeder:
gooly: have you looked in the journal tab, was there a zero-devide?
FXT file too large, zero divide, or infinite loop - not returning from start/OnInit. (Add a print at start and at the return.)

Thank you WHRoeder.

 

I am afraid I am still not that skilled on programming, I have never handled the "print". How can I know if I have an infinite loop that happens exactly on 2006.11.03 05:37 and not on any of the 510 previous operations?

The code is very simple working with a single moving average, the establishment of SL and TP at the very time of opening the operation and a trailing stop (not working properly yet, but it just gives a 130 error so it can not modify a stop loss with an impossible price, but the original SL remains).

Operations are only closed when reaching either SL or TP, no conditional close in the code. The last operation (number 511) got to open, established the SL and TP, never reached the SL or TP prices and closed as if it got to the end of the testing period, everything would have worked perfectly if the testing period was to end on 2006.11.03 05:37 but there are still years to go up to 2014.

 

//+------------------------------------------------------------------+
//|                                                 Probando3.02.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property version   "1.00"
#property strict


   double lotesbase = 1;
   extern int IncrementoMedia = 100;
   extern double MultiSL = 0.5;
   extern double MultiTP = 6;
   extern int PorcentajeDD = 15;
   extern int PipsMinimosParaTS = 1000;
   bool OrdenSeleccionada, OrdenModificada;
   double EMA14_1Anterior;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double EMA14_0 = iMA(Symbol(), 0, 14, 0, MODE_EMA, PRICE_CLOSE, 0);
   double EMA14_1 = iMA(Symbol(), 0, 14, 0, MODE_EMA, PRICE_CLOSE, 1);
   double EMA14_2 = iMA(Symbol(), 0, 14, 0, MODE_EMA, PRICE_CLOSE, 2);
   double EMA14_3 = iMA(Symbol(), 0, 14, 0, MODE_EMA, PRICE_CLOSE, 3);
   double Atr1 = iATR(Symbol(), 0, 14, 0);
   double Incremento1 = MathAbs (EMA14_1 - EMA14_2);
   double Incremento2 = MathAbs (EMA14_2 - EMA14_3);
   if (OrdersTotal() == 0 && EMA14_1 != EMA14_1Anterior)
      {
      if (EMA14_1 > EMA14_2 && Incremento1 > IncrementoMedia * Point && Incremento1 > Incremento2)
         {
         ABRIROP(OP_BUY, Symbol(), 1);
         }
      if (EMA14_1 < EMA14_2 && Incremento1 > IncrementoMedia * Point && Incremento1 > Incremento2)
         {
         ABRIROP(OP_SELL, Symbol(), 1);
         }
      } 
   if (OrdersTotal() > 0)
      {
      OrdenSeleccionada = OrderSelect (0, SELECT_BY_POS, MODE_TRADES);
      if (OrderStopLoss() == 0)
         {
         switch (OrderType())
            {
            case OP_BUY :  
               {
               double sl = NormalizeDouble(Ask - (MultiSL * Atr1), Digits());
               double tp = NormalizeDouble(Ask + (MultiTP * Atr1), Digits());
               if (OrderStopLoss() == 0) 
                  {
                  OrdenModificada = OrderModify(OrderTicket(), OrderOpenPrice(), sl, tp, 0, clrNONE);
                  }
               break;
               }
            case OP_SELL : 
               {
               double sl = NormalizeDouble(Bid + (MultiSL * Atr1), Digits());
               double tp = NormalizeDouble(Bid - (MultiTP * Atr1), Digits());
               if (OrderStopLoss() == 0) 
                  {
                  OrdenModificada = OrderModify(OrderTicket(), OrderOpenPrice(), sl, tp, 0, clrNONE);
                  }
               break;
               }
            }
         }
      }
  EMA14_1Anterior = EMA14_1;
  }
  
  
  
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+




//--------------------------------------------------------------------
//----ABRIR OPERACION-------------------------------------------------
//--------------------------------------------------------------------
void ABRIROP (uint tipoop, string simbolo, double lotes)   
   {
   int ticket = 0;
   if (lotes < 0.01) lotes = 0.01;
   lotes = NormalizeDouble(lotes, 2);
   if (tipoop == 0)
      {
      if(AccountFreeMarginCheck(simbolo,tipoop,lotes) > 0.5) 
         {
         ticket = OrderSend (simbolo, tipoop, lotes, MarketInfo(simbolo, MODE_ASK), 5, 0, 0, NULL, 0, 0);
         if (ticket > 0) 
            {
            Alert(ticket, " ", " abierta ", simbolo);
            }
            else
            {
            Sleep (10000);
            }
         }
      }
   if (tipoop == 1)
      {
      if(AccountFreeMarginCheck(simbolo,tipoop,lotes) > 0.5) 
         {
         ticket = OrderSend (simbolo, tipoop, lotes, MarketInfo(simbolo, MODE_BID), 5, 0, 0, NULL, 0, 0);
         if (ticket > 0) 
            {
            Alert(ticket, " ", " abierta ", simbolo);
            }
            else
            {
            Sleep (10000);
            }
         }
      }
   }


//--------------------------------------------------------------------
//----CERRAR OPERACION------------------------------------------------
//--------------------------------------------------------------------
void CERRAROPERACION (uint ticket)
   {
   bool OrdenCerrada;
   OrdenSeleccionada = OrderSelect (ticket, SELECT_BY_TICKET, MODE_TRADES);
   if (OrdenSeleccionada == TRUE)
      {
      if (OrderType() == OP_BUY)
         {
         OrdenCerrada = OrderClose (ticket, OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5);
         if (OrdenCerrada == TRUE) Alert(ticket, " ", OrderComment(), " cerrada");
         }
         else
         {
         OrdenCerrada = OrderClose (ticket, OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5);
         if (OrdenCerrada == TRUE) Alert(ticket, " ", OrderComment(), " cerrada");
         }
      }
   }  

 See? Very simple code.

Carl Schreiber
6395
Carl Schreiber 2014.10.02 07:40  

Just put at several places of the OnTick()-function:

if (Time[0] > D'2006.11.03 05:35') Print("I am now at line: ",__Line__);

(In case the last valid entry of your EA is dtd 2006.11.03 05:36).

Amadeusss
51
Amadeusss 2014.10.03 15:47  
gooly:

Just put at several places of the OnTick()-function:

(In case the last valid entry of your EA is dtd 2006.11.03 05:36).


Thank you very much gooly. I did what you say (thank you very, very  much, this is a good way to detect code errors even if it did not work this time). Well, I had to modify the date to one day earlier because I would have no prints on the journal. The result is that it prints all the lines running, but when it gets to  2006.11.03 05:37 it stops and does not run any longer. The EA clearly stops executing at that date, as the tester shows. Maybe some bug?
Carl Schreiber
6395
Carl Schreiber 2014.10.03 16:34  
Ok, and you EA stops at what line?
/ /12
To add comments, please log in or register