• 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

The Equilibrium Indicator —  Profiting from Mean-Reversion.

March 5, 2021 by systems

The above plot shows an example on the EURUSD hourly data plotted with the Equilibrium Indicator in blue. The full code can be find below:

def ema(Data, alpha, lookback, what, where):

# alpha is the smoothing factor
# window is the lookback period
# what is the column that needs to have its average calculated
# where is where to put the exponential moving average

alpha = alpha / (lookback + 1.0)
beta = 1 - alpha

# First value is a simple SMA
Data = ma(Data, lookback, what, where)

# Calculating first EMA
Data[lookback + 1, where] = (Data[lookback + 1, what] * alpha) + (Data[lookback, where] * beta)

# Calculating the rest of EMA
for i in range(lookback + 2, len(Data)):
try:
Data[i, where] = (Data[i, what] * alpha) + (Data[i - 1, where] * beta)

except IndexError:
pass
return Data

def deleter(Data, index, times):

for i in range(1, times + 1):

Data = np.delete(Data, index, axis = 1)

return Data

def jump(Data, jump):

Data = Data[jump:, ]

return Data

def equilibrium(Data, lookback, close, where):

# Calculating the moving average
Data = ma(Data, lookback, close, where)
Data = jump(Data, lookback)

# Calculating the distance from the moving average
Data[:, where + 1] = Data[:, close] - Data[:, where]

# Calculating the Exponential Moving Average of the Equilibrium
Data = ema(Data, 2, lookback, where + 1, where + 2)
Data = jump(Data, lookback)
Data = deleter(Data, where, 2)

return Data

# Using the function
my_data = equilibrium(Data, 5, 3, 4)

Filed Under: Machine Learning

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