Dear all,
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.
Thanks so much.
Juan
// Days of the week
IF DayOfWeek = 0 OR Dayofweek = 6 THEN
tradeok = 0
ELSE
tradeok = 1
ENDIF
// Friday 22:00 STOP operations
IF Dayofweek = 5 AND TIME = 220000 THEN
QUIT
ENDIF
Hi,
I am answering myself, :))
I think that:
IF Dayofweek = 5 THEN
DEFPARAM Flatafter = 220000
ENDIF
Hi,
It doesn’t work. DEFPARAM can’t be used like that.
Any suggestions???
(Reminder: I want to close the operations on Friday night at 220000, but I want the system to run from Monday to Friday without interruption)
Thanks in advance,
Juan
Try this one (I did not):
IF DayOfWeek = 5 AND time = 220000 THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
You close any trade, either LONG or SHORT at the time you want, on the day you want to.
You can’t use DEFPARAM in conditional statements, it’s an unchangeable directive to ProOrder, not an instruction.
Hi Roberto,
Gracie mille. I will try it right now and will let you know the results.
Juan
Hi Roberto,
It works. I have also added something to avoid launch any operation after 22:0000 on Friday.
// Friday 22:00 Close ALL operations.
IF DayOfWeek = 5 AND time = 220000 THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
Fridaynight = Dayofweek = 5 AND time>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 😉
Thanks again,
Juan