I use the following before entering the routine
datetime df = TimeCurrent()-(2*24*60*60); // equates to 2*24 hours datetime dt = TimeCurrent(); MB = MB + "Start @ "+TimeToString(df)+" to "+TimeToString(dt); HistorySelect(df,dt);
I have found the following post https://www.mql5.com/en/code/17622
which appears to solve my problems.
Still confused why open price is not correct
CHistoryPositionInfo Class - library for MetaTrader 5

Yes excellent - just found the library
Peter Williams #:I use the following before entering the routine
datetime df = TimeCurrent()-(2*24*60*60); // equates to 2*24 hours
You probably want two trading days, not two calendar days.
Find bar of the same time one day ago - MQL4 programming forum (2017)

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to convert a 'simple' EA from MT4 to MT5 to list History Orders - in particular I want PROFIT, Time OPEN & CLOSE etc
I have tried and had partial success shown in the messagebox (using string variable MB)
I use the following code
the deatails (downloaded report) are summarised as follows:-
Open Thu 15-Sep-22 11:30 correct
Ticket 247264318 correct
AUDUSD correct
sell No attempt to retrieve
Lots 0.01 No attempt to retrieve
Open 0.67414 NOT as shown in MessageBox
Close Thu 15-Sep-22 11:52 NOT as shown in MessageBox
Close Price 0.67488 NOT as shown in MessageBox
Profit 0.37 No attempt to retrieve
The OPEN price is 0.0000
The CURRENT PRICE is what should be the OPEN price and I am unable to find a CLOSE time or PRICE
If I look at HISTORYDEALS then they use a different ID --- Not the Ticket number shown here
Like to know / understand what instructiosn to use?
Any help appreciated