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:
1
2
3
4
5
6
7
myday=1
ifdayofweek=mydaythen
buy1contractsatmarket
endif
iflongonmarketthen
sell1contractsatmarket
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)?
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!
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.
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.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok