Topic: Close Order past x seconds

Hi i´m new in this Forum but i need help, i want to close the trade past 15 second, someone knows in which line of text this order goes and what is the order that must be placed. Thanks in advance. If someone has an EA with this order, it also helps me, and if it is possible, tell me in what line you have placed the order, in order to place the order in the future portfolios that you use.

Re: Close Order past x seconds

Do you have a special reason to close a position after 15 seconds?

Please note that if you modify the EA code, it will change the strategy logic and performance. The great value of EA Studio is to help you creating strategies with good backtest stats and corresponding trading results.

Anyway, you can do it easily. Add a global variable in the EA and store there the opening time of your position. At the OnTick function add a check if 15 seconds have passed since the opening and call the ClosePosition function.

Something like that:

long posOpenTime = 0;

void OnTick()
  {
   if(posOpenTime>0 && TimeLocal()>posOpenTime+15)
     {
      ClosePosition();
      posOpenTime=0;
     }
void OpenPosition(int command)
  {
    ...

   if (ticket>0)
     {
      posOpenTime=TimeLocal();
      break;
     }

Re: Close Order past x seconds

I get an error, I may not know how to place the code in the right place,