Trade History

 

Hi, please can anyone help me with the correct code to get the Deal Entry Price?

   HistorySelect(0,TimeCurrent());
//--- create objects
   string   name;
   uint     total=HistoryDealsTotal();
   ulong    ticket=0;
   double   price;
   double   profit;
   datetime time;
   string   symbol;
   long     type;
   double     entry;
//--- for all deals

   for(uint i=0; i<total; i++)
     {
      //--- try to get deals ticket
      if(ticket=HistoryDealGetTicket(i))

        {
        ORDER_STATE_
         price =HistoryDealGetDouble(ticket,DEAL_PRICE);
         time  =(datetime)HistoryDealGetInteger(ticket,DEAL_TIME);
         symbol=HistoryDealGetString(ticket,DEAL_SYMBOL);
         type  =HistoryDealGetInteger(ticket,DEAL_TYPE);

         entry =HistoryDealGetInteger(ticket,DEAL_ENTRY);         
     
    

When I use " HistoryDealGetDouble" it return error.

When I use "HistoryDealGetInteger" it compile but do not return the entry price.

All other variables work perfectly except the entry price.

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Deal Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You are long enough here you should have learned to search: https://www.mql5.com/en/search#!keyword=Deal%20history&method=2&module=mql5_module_codebase

There you have more than 200 examples answering your question.

 
Carl Schreiber #:

You are long enough here you should have learned to search: https://www.mql5.com/en/search#!keyword=Deal%20history&method=2&module=mql5_module_codebase

There you have more than 200 examples answering your question.

Found the answer, thanks.