• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Crypto Currency
  • Technology
  • Contact
NEO Share

NEO Share

Sharing The Latest Tech News

  • Home
  • Artificial Intelligence
  • Machine Learning
  • Computers
  • Mobile
  • Crypto Currency

Using The Average Slope As a Trading Indicator.

January 1, 2021 by systems

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).”

Filed Under: Artificial Intelligence

Primary Sidebar

Stay Ahead: The Latest Tech News and Innovations

Cryptocurrency Market Updates: What’s Happening Now

Emerging Trends in Artificial Intelligence: What to Watch For

Top Cloud Computing Services to Secure Your Data

The Future of Mobile Technology: Recent Advancements and Predictions

Footer

  • Privacy Policy
  • Terms and Conditions

Copyright © 2025 NEO Share

Terms and Conditions - Privacy Policy