This script is meant to calculate the Escape Velocity from the mean. According to Investopedia "Mean reversion is theory used in finance that suggests that asset prices and historical returns eventually return back to the long-run mean or average level of the entire data set."
Escape Velocity is the lowest velocity which a body must have in order to escape the gravitational attraction of a particular planet or other object, in this case the mean. It is recommended that you use a moving average with the same length as the ones that you decide to use for this indicator.
Escape Velocity= sqrt((2*Gravitational Constant * Mass)/Distance from the mean)
The Escape Velocity is in red and the velocity of price is in green. When price velocity (green) is positive and greater and than escape velocity (red) and price is above the mean, this would indicate that price is breaking away from the mean (bullish). When price velocity is negative and less than escape velocity and price is below the mean, this would indicate that price is breaking away from the mean (bearish).