Finding the closing time of the last position

Below I show you a version of a function from a few days ago. This time we want to get the closing time of the last position (chronologically). In one of the next entries I will show you how to use this function to filter false signals.

int lastCloseTime(int magic,int type) {

 int max=0;

 for(int i=0;i<OrdersHistoryTotal();i++) {
  if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {
   if(OrderMagicNumber()==magic) {
    if(OrderType()==type || type<0) {
     max=MathMax(OrderCloseTime(),max);
    }
   }
  }
 }

 return(max);
}

Note: I advise you to set the date range in the History tab of your terminal to cover the time period until now, otherwise there may be errors, because of a specific history access from the code level.

Share with your friends:

Send us your comments

Name (required)

Email (required)

Message

  • Facebook