There are some ways to detect changing of direction of an indicator:

- Calculate the slope or correlation of N period of a line. Reference to: https://realpython.com/python-statistics/ . Increasing when correlation is positive, and vice versa decreasing when correlation is negative.
- Calculate the percent change of N period of a line. Reference to: bt.indicators.RateOfChange or bt.indicators.PercentChange. Increasing when percent change positive and decreasing when percent change negative.

The first method is slow and lagging so much with big N, but not accurate with small N.

The second method is more accurate with small N and especially with stable/no-lag indicator, example: Fisher Transform, but it got the problem when the indicator signal cross ZERO line.

Do you have any better ideas to solve this problem? I can imagine one method to solve the second method is plus a number to the signal line, for all positive number to void the ZERO line crossing. But I hope that you have a better ideas.

Thank you very much!

]]>