Hello,
I know I can use the DEFPARAM commands FlatBefore and FlatAfter to tell my system the time to start and stop trading but does anyone know how to incorporate the day of the week as well. Example:
On Monday
DEFPARAM FlatBefore = 013000 // Cancel any pending orders, close any positions and prevent placement of additional orders by the trading system before 01:30:00 in the time zone of the strategy.
On Friday
DEFPARAM FlatAfter = 230000 // Cancel any pending orders, close any positions and prevent placement of additional orders by the trading system after 23:00:00 in the time zone of the strategy.
Thanks
Sorry it’s not possible to define specific days of week with FlatBefore or FlatAfter. The best you can do is to create a conditional variable that test the days you want to trade or to close your opened orders, like this :
daytotrade = dayofweek=1 OR dayofweek=2
if condition and daytotrade then ......
..
...
..
..
endif
Is it ok for you?
Hi Nicolas, Thanks for the update.and yes I think that works for me. I’ll test it in my system code
Hey
If i don´t want it to take positions on Fridays for example. How do i write it? Something like this?
k= dayofweek (friday)
if k then
allowtrade = 0
else
allowtrade = 1
endif