I have a code that scans all closed deals ( hedging ) in history but I want it to select the latest close deal. This code do
//--- variables for returning values from latest deal properties +++++++++++++++++++
ulong deal_ticket; // deal ticket
ulong order_ticket; // ticket of the deal was executed on
datetime transaction_time; // time of a deal execution
long position_ID; // position ID
string Dsymbol; // symbol of the deal
//--- set the start and end date to request the history of deals
datetime from_date=0; // from the very beginning
datetime to_date=TimeCurrent();// till the current moment
//--- request the history of deals in the specified period
HistorySelect(from_date,to_date);
//--- total number in the list of deals
int deals=HistoryDealsTotal();
//--- now process each trade
for(int i=0;i<deals;i++)
{
if((deal_ticket=HistoryDealGetTicket(i))>0)
{
transaction_time=(datetime)HistoryDealGetInteger(deal_ticket,DEAL_TIME);
order_ticket= HistoryDealGetInteger(deal_ticket,DEAL_ORDER);
Dsymbol= HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
position_ID= HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID);
}
}
es not seem to work properly any suggested tweaks?