Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
dividend harvest help

I'm new to this and I've ripped this backtest from someone else that I found in the forums... Can someone help me figure out how I would be able to edit the source to only buy stocks that are on a bullish macd trend?

I also want to explore buying the positions up to a week before the ex date, and selling up to a week after the ex date (based on user input or hard coding it). I'm thinking I'd need to re-code the logic for selling if I did that though.

Lastly, I want to be able to rank the bullish trending stocks that have upcoming ex dividends and then buy positions in the top few results.

I know this is a lot, but any bumps in the right direction on even just one of these things would be helpful!