Muhammad Elbermawi:
Why don't you store the one found and start searching from there?
Hello friends,
The following function is designed to search the history of the deals then it breaks when it finds the first deal out from below.
Is there a way in MQL5 to find the second or the third deal from below, and extract information from it?
A screenshot to show what I want to do
FYI.
void GetFirstHistory(ulong magic,string symbol,long &type, double &lot, double &profits,int counter = 1) { int cnt = 0; if(HistorySelect(0, TimeCurrent()) == true) { for(int i = HistoryDealsTotal() - 1; i >= 0; i-- ) { ulong ticket = HistoryDealGetTicket(i); if(ticket > 0) { if(HistoryDealGetInteger(ticket, DEAL_MAGIC) == magic && HistoryDealGetString(ticket,DEAL_SYMBOL)==symbol && HistoryDealGetInteger(ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) { type = HistoryDealGetInteger(ticket, DEAL_TYPE); lot = HistoryDealGetDouble(ticket, DEAL_VOLUME); profits = HistoryDealGetDouble(ticket, DEAL_PROFIT); if(++cnt>=counter)break; } } } } }
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
Hello friends,
The following function is designed to search the history of the deals then it breaks when it finds the first deal out from below.
Is there a way in MQL5 to find the second or the third deal from below, and extract information from it?
A screenshot to show what I want to do