The first intuitive step in calculating the indicator is to calculate a moving average based on the market price. We will use a simple moving average but feel free to test other types such as exponential and linear-weighted.

`def ma(Data, lookback, what, where):`for i in range(len(Data)):

try:

Data[i, where] = (Data[i - lookback + 1:i + 1, what].mean())

except IndexError:

pass

return Data

Now, we can use the above function in the below code snippet to add the slope function into our calculation:

def steepness_indicator(Data, lookback, steepness_period, what, where):# Calculating a Simple Moving Average

Data = ma(Data, lookback, what, where)# Calculating the Slope (Differences of Moving Averages)

for i in range(len(Data)):

Data[i, where + 1] = (Data[i, where] - Data[i - steepness_period, where]) / (i - (i - steepness_period))return Data

What the above function does is simply calculate a simple moving average, then loops around the totality of the data array and subtracts the current moving average by the one preceding it by a variable amount of time that we wish to specify using the **steepness_period **input, and finally dividing by the time interval which is the same as the steepness_period. The **where **variable is where you want to output the indicator. The **what **variable should refer to the closing price as it is the variable that we calculate the moving average on.

“To facilitate communication, we can refer to a Steepness Indicator with a 8-period moving average and a 3-period Steepness period as SI(8, 3).”