Hi,
I’m trying to prevent my system from taking a trade prior to 8pm Sunday night for a system in the US.. to avoid the ASX open. I have added this code however it does not prevent the trade entry.
noTradeTimeBlock = NOT (CurrentTime < 160000 AND CurrentTime < 200000 AND CurrentDayOfWeek = 0)
I have then included ‘noTradeTimeBlock’ in the buy order requirements. I understand this to say to remain false if the time is between 4pm & 8pm of a Sunday. Is there something incorrect here?
When backtesting the system, a trade is still taken at 19:10 of a Sunday night, which I’m trying to avoid. I do also have the PRT time settings set to New York UTC +04:00.
Do Not use CURRENTTIME, use either TIME (time when a bar closes) or OPENTIME (time when a bar opens).
Try this (not tested):
noTradeTimeBlock = OpenTime < 200000 AND CurrentDayOfWeek = 0
Hi @robertogozzi, thanks for the reply. I tried the code you suggested using ‘OpenTime’ or ‘Time’ and it works but begins to fail when I include the ‘CurrentDayOfWeek=0’. I am trying to avoid the opening of a trade in the hours before the markets open in New York time (8pm).
So, this works to exclude the trade within the time as below
noTradeTimeBlock = NOT ((Time >= 140000) AND (Time <= 200000))
but as soon as I add the CurrentDayOfWeek function it begins to fail to remove the trades in the time frame I am trying to avoid.
noTradeTimeBlock = NOT ((Time >= 140000) AND (Time <= 200000) AND (CurrentDayOfWeek=0))
So in plain terms, if it is a Sunday and between 2pm and 8pm I want the strategy not to open any trade. So ‘noTradeTimeBlock’ will positive or true only when it is not a Sunday & between 2pm & 8pm.
I don’t believe the syntax is incorrect but have I then used the ‘CurrentDayOfWeek’ function incorrectly?
Sorry, I incorrectly used CURRENTdayofweek, use OpenDayOfWeek
o or DayOfWeek, instead.
Same results. This really has me puzzled.
TIME or OPENTIME will use your time zone, not NY’s.
Did you take this into account?