Peter Williams:
I am trying to migrate to MT5 and really struggling with HISTORY.
I eventually came up with the following whgich works and maybe useful to someone.
I complete the following for each TicketNumber
//================================GetHistoryDetails START==============================+ void GetHistoryDetails() { HistorySelect(0,TimeCurrent()); { OrderOpenPrice = HistoryOrderGetDouble ( TicketNumber, ORDER_PRICE_OPEN); dt_open = HistoryOrderGetInteger ( TicketNumber, ORDER_TIME_SETUP); MySymbol = HistoryOrderGetString ( TicketNumber, ORDER_SYMBOL); HistorySelectByPosition(TicketNumber); for (int i = 0; i < HistoryDealsTotal(); i++) { ulong deal_ticket = HistoryDealGetTicket(i); if (HistoryDealGetInteger(deal_ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) { OrderClosePrice = HistoryDealGetDouble (deal_ticket, DEAL_PRICE); OrderProfit = HistoryDealGetDouble (deal_ticket, DEAL_PROFIT); dt_close = HistoryDealGetInteger (deal_ticket, DEAL_TIME); } } } return;// StrMyResult; // return the result } //==============================GetHistoryDetails END======================================+
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 migrate to MT5 and really struggling with HISTORY.
I tried to adopt some code - then gave up and been trying by trial and error. I have read some of the articles but just somehow don't get it.
MT4 seemed so simple.
If I download the HISTORY CSV I get large report which contains:
POSITIONS Then
ORDERS Then
DEALS Then
OPEN POSITIONS
I'd like to be able to identify from inside an EA a POSITION (from POSITIONS above) I see listed by Ticket Number.
(Example take the last 5 USDJPY - say - and list them on the screen with PROFIT/LOSS Time OPEN & CLOSE and visualise each with a trendline)
So I pass a TicketNumber to my sub which contains the following.
There doesn't seem to be a valid means of finding ORDER_PROFIT say and the I can't find a CLOSE PRICE.
The Select statement followed by OpenPrice & Symbol appear to be correct
Any help appreciated