I have coded the closing of my operations in my system on Friday night at 22:00h to avoid having open position during weekends and expose those positions to weekends gaps and charges from the broker.
I have opted for the command QUIT, but I am not sure if that will stop the system or just will close the operation until Monday at 00:00h
I am including the code and would appreciate any comments or even suggestions or alternative options.
It works. I have also added something to avoid launch any operation after 22:0000 on Friday.
1
2
3
4
5
6
7
// Friday 22:00 Close ALL operations.
IFDayOfWeek=5ANDtime=220000THEN
SELLATMARKET
EXITSHORTATMARKET
ENDIF
Fridaynight=Dayofweek=5ANDtime>220000
Oil Market close at around 23:00, and reopens after 00:00 everyday. At least at this hour there is a gap or inactivity everyday, but sometimes close before. In some cases I have noticed that cease all the trading around 220000, so just to be safe I have decided to set up closing operations on Friday at 22:00.
After that I noticed in the backtest that the system bought at 22:45 on Friday in two occasions, causing in one of them a gap of 243 points until Monday. So to avoid any involuntary buying or selling after 22:00 I have included the Fridaynight (doesn’t sound very professional, but it works 😉