hi guys
i just want to know whats the ticket of last closed order i wrote this just want to know if this way is correct or not
and one more thing why tickets are different in terminal than actual reports or in mql5!
tnX for help in advance
Your code looks at order ticket, you screenshot shows a position ticket. That's not the same.
A "last closed order" is not a thing with MT5.
Read the documentation and/or this article.
- www.mql5.com
Your code looks at order ticket, you screenshot shows a position ticket. That's not the same.
A "last closed order" is not a thing with MT5.
Read the documentation and/or this article.
tnX Alain,
so how can i get information of last closed order in MT5"MQL5"!?
it was easy in MT4, im kinda confused
tnX Alain,
so how can i get information of last closed order in MT5"MQL5"!?
it was easy in MT4, im kinda confused
I think that this is a confusion about the correct words. In MT/MQL there is no such thing as a "closed order". You submit an "order". If this order gets executed it results in a "deal". And you end up by having a "position". Then you can place another order, resulting in other deal, and another position. If your trading account is a netting account the second deal will be added/subtracted from your position. So your existing position gets modified in size. If you have a hedging account the second trade will result in a second position, even if it is on the same symbol.
Please read about the specifics of the words on this page: https://www.mql5.com/en/docs/trading
- www.mql5.com
I think that this is a confusion about the correct words. In MT/MQL there is no such thing as a "closed order". You submit an "order". If this order gets executed it results in a "deal". And you end up by having a "position". Then you can place another order, resulting in other deal, and another position. If your trading account is a netting account the second deal will be added/subtracted from your position. So your existing position gets modified in size. If you have a hedging account the second trade will result in a second position, even if it is on the same symbol.
Please read about the specifics of the words on this page: https://www.mql5.com/en/docs/trading
tnX WindMilMQL
the too many namings...
i tried with HistoryDeal still couldn't get what exactly what i needed,
so if i wanted to get exactly last finished Deal in history like my screenshot how to get it?
tnX WindMilMQL
the too many namings...
i tried with HistoryDeal still couldn't get what exactly what i needed,
so if i wanted to get exactly last finished Deal in history like my screenshot how to get it?
Am I correct that your screenshot is from the History tab in MT? If so, you can get the information about this by using the following code:
ulong LatestTicket = HistoryDealGetTicket(HistoryDealsTotal()-1); double Profit = HistoryDealGetDouble(LatestTicket,DEAL_PROFIT);
In this example am I using the deal with the highest index number. However, it might be that the deals are not indexed in the way you want. In that case you have to loop through all deals and look for the deal that matches your search criteria (e.g. symbol or date&time of execution). And then get the parameter of that particular deal.
Am I correct that your screenshot is from the History tab in MT? If so, you can get the information about this by using the following code:
In this example am I using the deal with the highest index number. However, it might be that the deals are not indexed in the way you want. In
that case you have to loop through all deals and look for the deal that matches your search criteria (e.g. symbol or date&time of
execution). And then get the parameter of that particular deal.
Thanks WindMilMQL,
yup as you mentioned above i test with this function, Problem is it return latest Deal by the Time the deal opened then closed
not the latest on closed Deal
in screen shot instead of returning :
2020.05.12 11.40.58 audnzd Buy with close on 2020.05.13 05.02.18
it returns
2020.05.12 13.32.08 usdjpy sell closed on 2020.05.12 22.32.36 since its the last deal actually created!
thats my dilemma!
i want to find latest closed by the close time not by the created time of the deal
Thanks WindMilMQL,
yup as you mentioned above i test with this function, Problem is it return latest Deal by the Time the deal opened then closed
not the latest on closed Deal
in screen shot instead of returning :
2020.05.12 11.40.58 audnzd Buy with close on 2020.05.13 05.02.18
it returns
2020.05.12 13.32.08 usdjpy sell closed on 2020.05.12 22.32.36 since its the last deal actually created!
thats my dilemma!
i want to find latest closed by the close time not by the created time of the deal
I see what you mean. The history is indexed by the time of opening, not by the time of closing. You are looking for a solution to how to get the closing time and then find the most recent one.
I have never tried this myself, but on the documentation page I see an enum called ENUM_DEAL_ENTRY, where you can select between "in" and "out". I don't know whether this can be used to find the timestamp that you are looking for.
See near the bottom of this documentation page: https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties
- www.mql5.com
I see what you mean. The history is indexed by the time of opening, not by the time of closing. You are looking for a solution to how to get the closing time and then find the most recent one.
I have never tried this myself, but on the documentation page I see an enum called ENUM_DEAL_ENTRY, where you can select between "in" and "out". I don't know whether this can be used to find the timestamp that you are looking for.
See near the bottom of this documentation page:
https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties
yup you are correct,
by default it returns data on Opening Time not actual recent closed...
Enum deal entry let me try oh well its sunday i guess have to wait till tomorrow!
tnX again for help
That's a parameter mismatch please check the inputs.
1. Immediately returns the property value.
long HistoryDealGetInteger( ulong ticket_number, // Ticket ENUM_DEAL_PROPERTY_INTEGER property_id // Property identifier );
2. Returns true or false, depending on the success of the function. If successful, the value of the property is placed into a target variable passed by reference by the last parameter.
bool HistoryDealGetInteger( ulong ticket_number, // Ticket ENUM_DEAL_PROPERTY_INTEGER property_id, // Property identifier long& long_var // Here we accept the property value );
I think you can use a loop of simple time > comparison to get the desired results.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi guys
i just want to know whats the ticket of last closed order i wrote this just want to know if this way is correct or not
and one more thing why tickets are different in terminal than actual reports or in mql5!
tnX for help in advance