Hi guys,
I'm just wondering if there is a function to get the position opening time here in MQL5? I've read the various trade functions and the data structures but can't seem to locate this function. I'm intending to close a position based on a fixed time after being opened if the takeprofit and stoploss hasn't been triggered yet. Thanks in advance!
PositionGetInteger(POSITION_TIME). Returns a datetime type.
For more info on position properties, click a green link in your post.
PositionGetInteger(POSITION_TIME). Returns a datetime type.
For more info on position properties, click a green link in your post.
Hi polymath,
... and you have to select first with PositionSelect() https://www.mql5.com/en/docs/trading/positionselect
- www.mql5.com
Hello guys,
I want to get last opened order ticket and it's entry time in MQL 5 but I couldn't do this , please help me
I did this before in mql4 with bottom block code
ulong lastOpenTicket() { int lastOpenTime = 0, needleTicket = 0; for(int i = (OrdersTotal()-1); i >= 0; i --) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { int curOpenTime = OrderOpenTime(); if(curOpenTime > lastOpenTime) { lastOpenTime = curOpenTime; needleTicket = OrderTicket(); } } } return needleTicket; }
I want to change my codes to MQL 5 , please Help me , thanks
Hello guys,
I want to get last opened order ticket and it's entry time in MQL 5 but I couldn't do this , please help me
I did this before in mql4 with bottom block code
I want to change my codes to MQL 5 , please Help me , thanks
Search for the most recent position and display information about it.
- 2021.03.12
- www.mql5.com
double SonPozKarHesapla() { double _karToplam=0; datetime _zaman=0; for(int i=0; i<PositionsTotal(); i++) { ulong bilet=PositionGetTicket(i); long sihirliIslem=PositionGetInteger(POSITION_MAGIC); if(PositionSelectByTicket(bilet) && sihirliIslem==1923) { double _kar=PositionGetDouble(POSITION_PROFIT); datetime _zamanim=(datetime)PositionGetInteger(POSITION_TIME); if(_zamanim>_zaman) { _karToplam=_kar; _zaman=_zamanim; } } } return _karToplam; }
- 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'm just wondering if there is a function to get the position opening time here in MQL5? I've read the various trade functions and the data structures but can't seem to locate this function. I'm intending to close a position based on a fixed time after being opened if the takeprofit and stoploss hasn't been triggered yet. Thanks in advance!