For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
The best method to detect changing of direction of an indicator?

Hello,
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/pythonstatistics/ . 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/nolag 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!