Need clarification on cheating/replay/timers to buy at open and sell minutes before it closes
-
So on the 1H chart, I am just trying to buy when a candle opens and sell 5 minutes before it closes.
I've read some docs:
https://www.backtrader.com/blog/posts/2017-05-01-cheat-on-open/cheat-on-open/
https://www.backtrader.com/docu/data-replay/data-replay/
https://www.backtrader.com/docu/timers/timers/But I kinda need an ELI5 and clarification on what they do.
To buy at the open, it sounds like
cheat-on-open
might be what I want. From what I understand, by default things operate onnext()
when candles close and indicators are recalculated, so it's "cheating" if you try to do something before the complete close of the current candle, so you only have the previous candle close to work with at the open of the current candle, and you don't know where that opening current candle will end up. Am I understanding this correctly?Also I'm not sure of the difference between
resample
andreplay
, but it sounds like 'replay' might be along the lines of what I want. I also saw that I can add timers. To sell 5 minutes before a candle closes, should I usenotify_timer
orreplay
?Thanks!
-
Um, this may also be relevant: https://www.backtrader.com/docu/filters-reference/#barreplayer_open