I know that the lower level you go the more able you are to accidentally induce look forward bias. Especially with R and quantstrat since you can write orders directly to the book.
What indicators do you usually lag? what can you check to make sure you don't have look ahead bias?
Personally I just use everything as is, but I know in the webinar @IlyaKipnis lagged his ATR. But he also said that quantstrat is a next bar execution system. So does that negate having to explicitly lag thing?
maybe @bigmike or any other big R people will know.
The reason I lag the ATR is that I buy on open, and ATR is calculated on close. So whichever bar quantstrat buys at, it needs to know the ATR value. However, since we only are dealing with the open of the bar (close is unknown yet), I use the lagged ATR, rather than the ATR computed for the bar at its close.
Beyond that, when using quantstrat, all the computations are vectorized, so you can't get an indicator that looks ahead unless you deliberately use something like negative lag.
The answer, as usual is: of course, you *can* fool yourself. No machine will stop that. But in quantstrat, you have to be more deliberate about doing that than most places.
The following 2 users say Thank You to IlyaKipnis for this post:
@IlyaKipnis again thanks so much for the fast and really well written responses. I really appreciate it as someone getting started using R.
So as long as i don't use negative lag explicitly, then its very difficult to get it to have a look ahead bias. Thats fantastic. As long as I keep my own development in check and quantstrat does its job then I should be fine about lookahead. I was considering if all my indicators needed lagging because of the architecture of quantstrat and using more complex strategies. But I guess not.
I also highly recommend initially studying the output of the data frame against actual values from another platform with the same indicator, so you can understand and verify the accuracy of any new functions or tools you build that generates signals.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
The following user says Thank You to Big Mike for this post: