I am backtesting a simple moving average strategy, using price (for example daily bars) and a simple moving average. I want to find out how often the price crossed over or below the moving average over my historical data for stock X. In other words I want to find out the total number of crossovers.
I also want to find out the maximum / minimum point between each crossover. As price moves around the moving average it is sometimes above the average and sometimes below. I want to measure theese alterations. By this I mean the highest distance in ticks or percent between crossover A and crossover B, using crossover A as the baseline.
Please look at this picture to clarify what I mean:
I would appreciate any help that can point me in the right direction on how to code this in Python :-)