ghs296:
DEAL_TIME hello everyone
I want to get the time to open a closed trade. I took help from artificial intelligence and it suggested this program line.
datetime openTime = HistoryDealGetInteger(lastDealTicket, DEAL_ENTRY_TIME);
But DEAL_ENTRY_TIME does not exist in mql5. You may help. thank you
Use the documentation, it's giving the correct info
I see a code example also for this:

Documentation on MQL5: Trade Functions / HistoryDealGetInteger
- www.mql5.com
Returns the requested property of a deal. The deal property must be of the datetime, int type. There are 2 variants of the function. 1. Immediately...
ghs296 #:
Thank you for your attention, but I saw this document and DEAL_TIME is the closing time of the deal and not the opening time of the deal.
Thank you for your attention, but I saw this document and DEAL_TIME is the closing time of the deal and not the opening time of the deal.
A deal is only dealing with the closing time. So you don't work with deals then. You need to record the time when a position is executed and save TimeCurrent() in a variable.
if(tradeSignal && !finishedTrade){ makeBuyPosition... positionOpenTime = TimeCurrent(); finishedTrade = true; } now reset "finishdTrade" flag back to false inside a deal condition (or in another way)
better approach might be to use POSITION_TIME
for (int i = PositionsTotal() - 1; i >= 0; i--){ datetime positionOpenTime = PositionGetInteger(POSITION_TIME); }

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
datetime openTime = HistoryDealGetInteger(lastDealTicket, DEAL_ENTRY_TIME);