
I’ve searched in lots of locations for an analogue of perform : OrderCloseTime() . Such a perform doesn’t exist in МQ5. I share my strategy to get the closing time of an open place in MQ5. I exploit within the knowledgeable advisor a easy loop for a specified variety of open positions: / and first make static var /
……
static lengthy Close_Time_buy ; ......... .......... double GetLastSL_buy = 0; for(int i = 0; i < PositionsTotal(); i++) { if(m_position.SelectByIndex(i)) if(m_position.Image() == _Symbol) if(m_position.PositionType() == POSITION_TYPE_BUY) if(m_position.Magic() == Magic_number) count_buy_orders++; GetLastSL_buy = PositionGetDouble(POSITION_SL); } if( GetLastSL_buy != 0) Close_Time_buy = TimeNow;
……………..
When closing the place, with SL or TP, the time of this motion is counted and saved within the static variable. You may reset it everytime you need in your code.
The identical is finished for brief place.
I hope this may be of assist to many knowledgeable advisor builders.
Look ahead to my new merchandise: https://www.mql5.com/en/customers/esebg
Good luck to all merchants.