HI, so i'm trying to make an algorithm that uses a 20 day moving average and buys the asset when the moving average moves from a negative gradient to a positive one ie at a local minima, and then uses the next maxima as a signal to sell the asset. I'm pretty unsure about how to register gradients though of the moving average to implement this. Does anyone have any suggestions on how to did this. Thanks in advance!