Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using data from the previous bar?

Hi all,

Wondering if it's possible to use price data for a security from a previous day, so as to identify intersection points. For instance, if I wanted to make a trade when yesterday's SMA was above the closing price but today's SMA is below the closing price (thereby identifying a crossover point), how would I do that? Or, as another maybe simpler example if I wanted to do something when yesterday's MACD was below zero but today's MACD is above zero, how would that work?

Sorry if this question has already been answered, but I looked through the forum and some posts and didn't find much. Thanks in advance for any help! This community rocks!

1 response

Hello Jacob,

I have a few lines of code but they don't work as I have not yet been able to find a cross. Maybe someone can see what is wrong. I've used the TA-LIb technical indicator library for the SMA, a dictionary of price+SMA to keep track of multiple securities, and a deque to store yesterday's and today's results.

P.