Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Get the previous value of indicator

Hi, I adapted the MACD algorithm to behave like Linda Rashke's 3-10 oscillator and applied a simple buy and sell rules for manually selected securities. It seems to work as I expect, thought some transactions I'm not sure whey they are happening. This issue aside, I'd like to be able to add here another buy and sell logic. I want this algo to buy when macd line is higher than signal line AND the current value of macd is higher than the macd value of the previous trading day(or minute for minute based data). In other words I'd like to add a rule based on the geometry of the macd line and buy only when there is no peak, meaning, when macd values are going up and sell when there is a peak, meaning, when current macd value is lower than the previous one.
Any help would be appreciated. Thanks