Download MetaTrader 5
To add comments, please log in or register
Create Forum topics and improve your rating!
RodrigoMT5
50
RodrigoMT5 2015.09.27 20:38 

If I remove conditionals at line 1 and 2, it works fine getting the profit about time that I want, the problem is that i want to get only a specific  EA profit. Doing this bellow i receive 4755 error(trade deal not found). Why it does not work? 

double getResultadoDiarioEA(){
   double retorno = 0;
   datetime dataInicial = getDataInicioPregaoAtual();
   datetime dataFinal=TimeCurrent();
   
   HistorySelect(dataInicial, dataFinal);
   uint total=HistoryDealsTotal();
   ulong ticket=0;
   for(uint i=0; i < total; i++){
      ticket = HistoryDealGetTicket(i);
      if (HistoryDealSelect(ticket)){      //1
         if (HistoryDealGetInteger(ticket, DEAL_MAGIC) == meuMagic){              //2
            retorno = retorno + HistoryDealGetDouble(ticket, DEAL_PROFIT);
         }
      } else {
          Print ("Erro encontrado ==> " + GetLastError());
      }
   }
   return retorno;
}

Trinh Dat
37203
Trinh Dat 2015.09.28 01:56  
double getResultadoDiarioEA(){
   double retorno = 0;
   datetime dataInicial = getDataInicioPregaoAtual();
   datetime dataFinal=TimeCurrent();
   
   HistorySelect(dataInicial, dataFinal);
   uint total=HistoryDealsTotal();
   ulong ticket=0;
   for(uint i=0; i < total; i++){
      ticket = HistoryDealGetTicket(i);
         if (HistoryDealGetInteger(ticket, DEAL_MAGIC) == meuMagic){              //2
            retorno = retorno + HistoryDealGetDouble(ticket, DEAL_PROFIT);
         }
   }
   return retorno;
}
RodrigoMT5
50
RodrigoMT5 2015.09.28 04:15  
Trinh Dat:
i tried it but didnt work as well. there is no error but always return zero.
Tan Phan Ngoc
1332
Tan Phan Ngoc 2015.09.28 04:49  
Never EA get profit so long.
Roberto Jacobs
46341
Roberto Jacobs 2015.09.28 06:57  
RodrigoMT5:

If I remove conditionals at line 1 and 2, it works fine getting the profit about time that I want, the problem is that i want to get only a specific  EA profit. Doing this bellow i receive 4755 error(trade deal not found). Why it does not work? 

double getResultadoDiarioEA(){
   double retorno = 0;
   datetime dataInicial = getDataInicioPregaoAtual();
   datetime dataFinal=TimeCurrent();
   
   HistorySelect(dataInicial, dataFinal);
   uint total=HistoryDealsTotal();
   ulong ticket=0;
   for(uint i=0; i < total; i++){
      ticket = HistoryDealGetTicket(i);
      if (HistoryDealSelect(ticket)){      //1
         if (HistoryDealGetInteger(ticket, DEAL_MAGIC) == meuMagic){              //2
            retorno = retorno + HistoryDealGetDouble(ticket, DEAL_PROFIT);
         }
      } else {
          Print ("Erro encontrado ==> " + GetLastError());
      }
   }
   return retorno;
}

//probably should have

return(retorno);
RodrigoMT5
50
RodrigoMT5 2015.09.28 11:34  
3rjfx:
3rjfx, unfortunately there is no syntax problem because if i remove conditionals at line 1 and 2, it works fine returning all my profit for the this period. My idea is to get a profit only for a specific EA and magic number was supposed for solve this, I don´t understand why its so hard.  
Alain Verleyen
Moderator
30640
Alain Verleyen 2015.09.28 12:34  
RodrigoMT5:
3rjfx, unfortunately there is no syntax problem because if i remove conditionals at line 1 and 2, it works fine returning all my profit for the this period. My idea is to get a profit only for a specific EA and magic number was supposed for solve this, I don´t understand why its so hard.  
You have to debug your code. What are the dates ? How many deals are selected ?
RodrigoMT5
50
RodrigoMT5 2015.09.28 14:03  
Alain Verleyen:
You have to debug your code. What are the dates ? How many deals are selected ?

Alain,

dates are fine because without conditionals I get the right value of all my profit for this period. The problem is about getting some information about the deal. I debugged and could check that my deal has no magic number, but I use magic in every order that I send. What I want to know is why mt5 does not save my magic.  

Alain Verleyen
Moderator
30640
Alain Verleyen 2015.09.30 09:30  
RodrigoMT5:

Alain,

dates are fine because without conditionals I get the right value of all my profit for this period. The problem is about getting some information about the deal. I debugged and could check that my deal has no magic number, but I use magic in every order that I send. What I want to know is why mt5 does not save my magic.  

How are closed your positions, by SL/TP ?
RodrigoMT5
50
RodrigoMT5 2015.10.02 00:36  
Alain Verleyen:
How are closed your positions, by SL/TP ?
yes, sl or tp.
Alain Verleyen
Moderator
30640
Alain Verleyen 2015.10.03 13:56  
RodrigoMT5:
yes, sl or tp.
This is done by the server, not your EA, then these deals don't have a magic number.
/
To add comments, please log in or register