Hello,
I was trying a new strategy that requires the buy order to be executed on Mondays. I have been testing the following very basic code:
myday=1
if dayofweek=myday then
buy 1 contracts at market
endif
if longonmarket then
sell 1 contracts at market
endif
however this code does not trigger any buys, however if I use the same code and change the number of the variable “myday” to 2, 3, 4 and 5 it does triggers buy. Any reason why the buy will not be triggered on Mondays (dayofweek=1)?
Thanks!
If you use it on a Daily TF you won’t get correct values, since DAYOFWEEK refers to the candle when your trade will be entered, it works with intraday TFs.
I suggest you use OPENDAYOFWEEK, since it always works!
myday=1
if opendayofweek=myday then
buy 1 contracts at market
endif
if longonmarket then
sell 1 contracts at market
endif
I have the same problem. When I use “opendayofweek” instead “dayofweek” with opendyofweek = 1 then it works, thats true. But it opens also on Tuersday and not on Monday. Therefore the result is the same as if i would use dayofweek = 2. But when I use opendyofweek = 0, which should refer to open a position at Monday Morning, then the result is the same like with dayofweek = 1, nothing happens.
What could be the reason?
Thanks
Keywords starting with OPEN (OpenDate, OpenTime, OpenDayOfWeek, etc…) return the Date, Time, DayOfWeek, etc… when a candle opens, otherwise data returned are those when a candle closes.