I want to call yesterday’s hourly ATR for IG’s EURUSD contract during European futures opening hours. My trading platform is set to CET, Central European Time. If I do this in backtest I can use the following code snippet to store the average true range in the variable ATR:
1
2
3
4
5
TIMEFRAME(Hourly)
IFTIME=220000THEN
ATR=AverageTrueRange[14](close)
ENDIF
I can then call ATR during the following day.
Backtest will treat Sunday data as Monday. However, I am uncertain how Sunday data is treated in live algos. Will the IF-clause run on DayOfWeek=1 give me Sunday data or will it give me Friday’s data?
Any time the code is run on a candle with a closing time of 2200 it will store the ATR based on that candle and the previous 13. If there is a Sunday 2200 candle then it will change the value. If you want to avoid those candles then just do this:
Thanks @Vonasi for you tidying of my original post and for your suggestion! That effectively eradicates this problem (which is “invisible” in backtests).
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.