Bullish and Bearish Divergence MACD/RSI

To get it i thought for example to find first low, than the previous low indexes.
Then get prices compare them. Then get indicator's values and compare them too. I got stuck at getting second low/high. Please help.

The problem is that self.data.high(self.high_first - 1) is not a valid construct. Because self.high_first will be determined at runtime, whereas a delayed line (using parenthesis) needs to know the value from how many periods ago it will returning.

The problem is that self.data.high(self.high_first - 1) is not a valid construct. Because self.high_first will be determined at runtime, whereas a delayed line (using parenthesis) needs to know the value from how many periods ago it will returning.