• 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 Augmented Bollinger Bands.

December 25, 2020 by systems

To code the Augmented Bollinger Bands — ABB in Python, we need first to code the exponential moving average, which we can see how to do below:

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

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

Then, we can incorporate the function above to the one below and get the Augmented Bollinger Bands.

def augmented_BollingerBands(Data, boll_lookback, standard_distance, what, high, low, where):

# Calculating means
ema(Data, 2, boll_lookback, high, where)
ema(Data, 2, boll_lookback, low, where + 1)

volatility(Data, boll_lookback, high, where + 2)
volatility(Data, boll_lookback, low, where + 3)

Data[:, where + 4] = Data[:, where] + (standard_distance * Data[:, where + 2])
Data[:, where + 5] = Data[:, where + 1] - (standard_distance * Data[:, where + 3])

return Data

The below plot shows the AUDUSD hourly data with the Augmented Bollinger Bands of 20-periods and 2 standard deviation. We can abbreviate it to ABB(20, 2) to facilitate communication.

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