I just added the ability to specify the start and end date of the trading to my EA, however, I discovered a weird behaviour!
If I have specified the starting date for trade from
2016.05.01 00:00:00
and the end date to
2016.05.10 00:00:00
the EA trades from 2015.05.02 00:00
to 2016.05.12 14:02
but if I specified the date from2016.06.01 00:00:00
to 2016.06.10 00:00:00
it trades from 2016.06.01 00:00
to 2016.06.10 14:53
Here is my code:
extern datetime StartDate = __DATETIME__;
extern datetime EndDate = __DATETIME__;
int isTrading = 0;
if ( StartDate < EndDate ) {
if ( TimeCurrent() > StartDate
&& TimeCurrent() < EndDate
) isTrading = 1;
} else {
if ( TimeCurrent() > StartDate
|| TimeCurrent() < EndDate
) isTrading = 1;
}
I don't know what is wrong here, any help will be much appreciated.
Thank you in advance.