Hi all,
Just finding my feet with this system so have a simple question. Is there anyway to ignore the sunday bar when backtesting? I know I can remove it from the charts however it appears that when i write a rule and backtest it still takes it into account. Thanks for your help.
Do you want the Sunday bar to be ignored by indicators calculation? or just avoid Sunday to not launch any order?
Hi Nicolas,
My strategy entry is on the previous bars high so i ideally want to be able to backtest without the sunday bar being factored in. Is this possible?? I have worked out how not to trade on the sunday bar. Thanks for the reply.
If you are using the previous day High to decide your entry condition, just add a comparison with the day of the week to know you are not using the Sunday bar:
if DayOfWeek[1]=7 then
myHigh = High[2] //store friday high is yesterday was Sunday
else
myHigh = High[1] //else we store the previous day high
endif
Then use myHigh value in your conditional statement instead of High. Hope it is clear.
Hi Nicolas,
I have a similar requirement to ignore Sunday bars.. Ideally My strategy is affected by the Sunday bars as (1) I count the number of preceding bars for re-entry (2) I use daily closes.
Is there a way to backtest without Sunday Bars?
I used DayOfWeek to overcome the situation, but there’s an error. Please look at my screenshot. I “graph DayofWeek”. Thursdays, Fridays and Sundays all return the value of 5.. Is there a bug?
Thanks!
CY
Are you in a Weekly timeframe?
Also, a quick tip to get the day of the week when the bar has opened, is to use OpenDayOfWeek instead.
Hi Nicolas,
Thanks for the info!
I’m using Daily bars.
I’ve swapped OpenDayofWeek for DayofWeek. It works better now, with Monday = 1, Tues = 2.. But both Fridays and Sundays have the value of 5.. My code is:
IF not LongOnMarket AND Count = 3 and OpenDayofWeek <> 5 THEN
StopLoss = close – 2 * AverageTrueRange[40](close)
BUY PositionSize shares at market
Endif
That basically also rules out entering the market on Fridays too..
Any suggestions?
Thanks!
CY
same problem for me on the 1H time frame. I have tried opendayofweek, currentdayofweek, dayofweek, all three returned 5 for a Sunday bar. So impossible currently to identify a sunday bar???
Hi,
I have the same problem. Dayofweek is not 7 for sundays in daily graphs. It must be a bug.
However I did find a trick to identify if a bar is a sunday. The costant “Hour” is 23 when the script is run on a sunday and 1 (i think) on normal weekdays.
//Jonas