Really disappointed with ATC 2012 - page 2

 

The error you get make sense to me (if my analysis is correct).

You're using CheckLoadHistory wich is very failsafe, build 695 compliant and works just fine for me (it should work for you too if implemented in a while statement that is not broken later). The error then is not even related to the history of symbol data nor its synchronization but with the history of deals. Because at the start of the competition or when your first order has not been filled yet you have no deals, thus you're using a wrong index at HistoryDealGetTicket (-1 in the first case) leading to a ticket number of zero (invalid). Further calls to HistoryDealGetX using that invalid ticket will result in null pointers for reference types (strings). The error is given when that invalid pointer is accessed by simb_actual.getMultiplicador() or inside miListaSimbolos.getSimbolo(HistoryDealGetString(ticket,DEAL_SYMBOL)). All this assuming that the last lines of code you posted (the failing code) are executed at program initialization or at the OnTick() handler.

Validations you should have implemented in your failing code:

  • Check for total numbers of deals: if(HistoryDealsTotal() > 0).
  • Check ticket number: if(ticket > 0).

You should have done something like this:

//...
NodoSimbolo *simb_actual;
   NodoPosSimbolo *pos_simb_actual;
     
   HistorySelect(0,TimeCurrent());
   if(HistoryDealsTotal() > 0) // First validation.
   {
      int ticket = (int)(HistoryDealGetTicket(HistoryDealsTotal()-1));
      if(ticket > 0) // Second validation..
      {
         simb_actual = miListaSimbolos.getSimbolo(HistoryDealGetString(ticket,DEAL_SYMBOL));
         pos_simb_actual = miListaPosSimbolos.getSimbolo(HistoryDealGetString(ticket,DEAL_SYMBOL));
         
         if (simb_actual == NULL || pos_simb_actual == NULL) return; // Just in case.
         
         double mi_multiplicador = simb_actual.getMultiplicador();  // <= This is the line of the error
//...

The big question here is why this didn't happen in your own backtesting: Chances are that for developing your EA you were using an account that already have deals from manually placed orders (or placed by other EAs). If so then the biggest mistery is why it passed the automated testing without errors.

This is all i can deduce right now. I'm terribly sorry for what happened to you this year, your report looked very promising.

 
The big question here is why this didn't happen in your own backtesting: Chances are that for developing your EA you were using an account that already have deals from manually placed orders (or placed by other EAs). If so then the biggest mistery is why it passed the automated testing without errors.

This is all i can deduce right now. I'm terribly sorry for what happened to you this year, your report looked very promising.

I agree with you in that.

It's interesting your theory, but there are some points I wanted to explain a bit further:

When your account is just created, there's one deal: the initial deposit. So 

int ticket = (int)(HistoryDealGetTicket(HistoryDealsTotal()-1));

gives you this initial ticket, and it's not equal to zero. What will give you zero is HistoryDealsTotal()-2 , in the case of the account just created and no deals have been done, but only the initial deposit.

But it is true that 

Print("ticket symbol: ", HistoryDealGetString(ticket,DEAL_SYMBOL));

Will return nothing in the case of this first deal of initial deposit, as this ticket is not associated with a symbol. So yes, my code fails in that point.

BUT, what is even weirder than what you say is that this snippet of code is inside a function which is called in the OnTrade() method. Understand anything? Because I don't. 

Anyway, thanks TripleHeinz for your analysis. Following your indications, in my future eas I will always check the return of my functions, and not assume that what they return is what I expect, but the opposite: I have to assume that what the function returns is not what I expect and I must manually recheck that value.

 
When your account is just created, there's one deal: the initial deposit.

You're absolutely right, i missed that one. The initial deposit is deal #1, i checked in the journal log when testing, it is also displayed in the deal history in the atc.

Taking that into account it is exactly as you said:

Will return nothing in the case of this first deal of initial deposit, as this ticket is not associated with a symbol. So yes, my code fails in that point.

BUT, what is even weirder than what you say is that this snippet of code is inside a function which is called in the OnTrade() method. Understand anything? Because I don't.

If the initial deposit is reflected by a deal then OnTrade() will be triggered (in pair with the error).

Why the EA worked in your tests is still a mistery to me. But at least we know where the error is triggered and how to fix it by checking the returns of functions.

 
Thank a lot. That is great solution.
Reason: