stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

N-days exit
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2970
Page 1 of 1
Author:  glabbeek [ Sat Aug 10, 2013 8:25 pm ]
Post subject:  N-days exit

I've been searching high and low, but I can't find this simple exit.

For testing purposes I need an EA that closes a trade after a certain number of days or bars.

By using this method you can use MyFXbook data to find the sweet spot of a certain EA. You can test if it goes into profit as expected, the average low point before going into profit and much more. Because it is a timed exit, it will not be bias of an exit strategy.

I'm surprised that I can't find any EA doing just this simple task.

Does anybody have an exit that can handle this, or know where to find it?

Regards,
Author:  fxdaytrader [ Sun Aug 11, 2013 7:04 am ]
Post subject:  Re: N-days exit

Not testet, but I think this should work, e.g.:

int days=5;
if (iBarShift(Symbol(),PERIOD_D1,OrderOpenTime()) >= days) OrderClose(.....
Author:  glabbeek [ Mon Aug 12, 2013 6:30 am ]
Post subject:  Re: N-days exit

Thanks,

I'll give this a try.
Author:  dudest [ Mon Aug 12, 2013 9:44 am ]
Post subject:  Re: N-days exit

Another way to do it:

Code: Select all

// Global variable
datetime TimeSinceLastTrade = 0;
..
..

// After sending order to take a trade
TimeSinceLastTrade = TimeCurrent();
..
..

// In your control/checking module
if( (TimeCurrent() - LastTradeTime) > (3600*36) ) //It's more than 36 hours (in seconds) since last trade was taken
{
   // close trade (e.g by ticket number)
}
Cheers!
All times are UTC Page 1 of 1