Tell the EA to close orders if in profit for a certain time

 

Hi, I am looking at my trades and, although the EA is doing quite well I have seen that it might be a good idea to exit some trades after some time. Due not having reached TP, it might get stuck in flat movements, so I would like to know if I can tell the EA:

If in Profit for X time, close all orders. 

If so, how could I code it?

 
YThi MJ: If so, how could I code it?

Each tick, see if in profit.

  1. If no, set a static/global datetime to zero.
  2. If yes and the datetime is zero, set it to current time.
  3. If yes, compare current time to the datetime and if greater than X, close all orders.
You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help 2017.04.21