Open position expiry

 

Hello.

May I know if it's possible to add expiration through TIME any open positions to close at loss or at profit.

This is like open positions are time bound using seconds or hours. 

Thanks. 

 
Vantages:

Hello.

May I know if it's possible to add expiration through TIME any open positions to close at loss or at profit.

This is like open positions are time bound using seconds or hours. 

Thanks. 

You can do it through code (OrderModify), but not manually through MT
 
Filter:
You can do it through code (OrderModify), but not manually through MT
Thanks. But, could you please give one specific example say if I have one open position that I only like to remain open for 60seconds and will not care either at loss or at profit. Sorry, currently I'm just using my mobile phone.
 
Vantages:
Thanks. But, could you please give one specific example say if I have one open position that I only like to remain open for 60seconds and will not care either at loss or at profit. Sorry, currently I'm just using my mobile phone.
Sorry mate, I misunderstood what you were asking. In that case, you will need to check the order either in OnTick or an event timer and if it reached the 60 seconds, close it with OrderClose() 
 

You can set expiration date on a pending order, but not in an open position.

The closing time must be in code. For example, with the function ...  

//----------------------------------- TIEMPO NETO POSICIÓN ABIERTA -------------------------------
double tiempoNetoPosic(string simb, mi_FECHA_HORA modo= _SEG)
{              //devuelve el tiempo en segundos TIEMPO EFECTIVO DE MERCADO
   datetime arTmpBarra[],
            horaIni= (datetime)PositionGetInteger(POSITION_TIME);,
            horaFin= TimeCurrent();
   double contTmp= horaIni>0? CopyTime(simb, PERIOD_M1, horaIni, horaFin, arTmpBarra): -1; //el inicio de las barras queda dentro del intervalo definido
   if(contTmp>0)
   {
      contTmp= contTmp*60;                   //+(horaFin-arTmpBarra[(int)contTmp-1])+(horaIni-arTmpBarra[0]);
      switch(modo)
      {
         case _DIA  : contTmp= contTmp/(60*60*24);   break; // calcula número de días
         case _HORA : contTmp= contTmp/(60*60);      break; // calcula número de horas
         case _MIN  : contTmp= contTmp/60;           break; // calcula número de minutos
         case _SEG  : contTmp= contTmp;                     // calcula segundos
      }
   }
   return(contTmp);          //devuelve -1 si ha habido error
}
 
It is enough to code a function to compare current time with order open time ... Once difference is >= 0, then close the order.
Reason: