Duration of an open position: full time, net time

 
If a position is kept open by weekend or holiday involved, how to measure the net time, real-time market that is open? 

If we use the following function we obtain the natural time but not the actual open market ...

double tiempoMercadoPosic(string simb= NULL, mi_FECHA_HORA modo= _SEG)
  {                                      //enum mi_FECHA_HORA {_AÑO=0,_MES=1,_DIA=2,_HORA=3,_MIN=4,_SEG=5,_DSEM=6,_DAÑO=7};
   double result=0, sgds=0;
   datetime horaApert= horaApertPosicion(simb);
   sgds= (double)(TimeCurrent()- horaApert);
   switch(modo)
   {
      case _DIA  : result= sgds/(60*60*24);   break; // calcula número de días
      case _HORA : result= sgds/(60*60);      break; // calcula número de horas
      case _MIN  : result= sgds/60;           break; // calcula número de minutos
      case _SEG  : result= sgds;                     // calcula segundos
   }
   return(result);
}

datetime horaApertPosicion(string simb)
  {
   datetime resp= -1;
   if(PositionSelect(simb)) resp= (datetime)PositionGetInteger(POSITION_TIME);
   return(resp);
  }

 Someone proposed method to obtain the net or real-time market?

 
josemiguel1812:
If a position is kept open by weekend or holiday involved, how to measure the net time, real-time market that is open? 

If we use the following function we obtain the natural time but not the actual open market ...

 Someone proposed method to obtain the net or real-time market?

Something like this :

datetime minutes[];
datetime openTime = (datetime)PositionGetInteger(POSITION_TIME);
int countMinutes=CopyTime(_Symbol,PERIOD_M1,openTime,TimeCurrent(),minutes);

Not perfectly accurate as you can have missing M1 bar. But you get the idea.

 
angevoyageur:

Something like this :

Not perfectly accurate as you can have missing M1 bar. But you get the idea.

Thank you very much
Reason: