Bollinger Indicator - Normalized

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

1 of 7 10-10-2020, 10:23 am
The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

def BollingerBands(Data, boll_lookback, volatility, onwhat, where_ma,


where_up, where_down):

# Calculating means
for i in range(len(Data)):
try:
Data[i, where_ma] = (Data[i - boll_lookback + 1:i + 1,
onwhat].mean())

2 of 7 10-10-2020, 10:23 am
The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

except IndexError:
passfor i in range(len(Data)):
Data[i, where_up] = ((Data[i - boll_lookback + 1:i,
onwhat].std()) * volatility) + Data[i, where_ma]

for i in range(len(Data)):
Data[i, where_down] = Data[i, where_ma] - ((Data[i -
boll_lookback + 1:i, onwhat].std()) * volatility)

return Data

Data[:, 7] = (Data[:, 3] - Data[:, 6]) / (Data[:, 5] - Data[:, 6])

import matplotlib.pyplot as plt

fig, ax = plt.subplots(2, figsize = (10, 5))


ax[0].plot(Data[-1500:, 3], color = 'black')
ax[0].grid()
ax[1].plot(Data[-1500:, 7], color = 'blue')
ax[1].axhline(y = -0.4, color = 'red', linewidth = 1)
ax[1].axhline(y = 1.4, color = 'red', linewidth = 1)
ax[1].grid()

3 of 7 10-10-2020, 10:23 am
The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

def boll_signal(Data, buy, sell, boll_percentage, upper, lower):

for i in range(len(Data)):
try:
if Data[i, boll_percentage] <= lower and Data[i - 1,
boll_percentage] > lower:
Data[i, buy] = 1
elif Data[i, boll_percentage] >= upper and Data[i - 1,
boll_percentage] < upper:
Data[i, sell] = -1
else:
continue
except IndexError:
pass
return Data

4 of 7 10-10-2020, 10:23 am
The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

5 of 7 10-10-2020, 10:23 am
The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

6 of 7 10-10-2020, 10:23 am
The Normalized Bollinger Indicator. Another Way to Trade the Range. B... https://medium.com/@kaabar.sofien/the-normalized-bollinger-indicator-...

7 of 7 10-10-2020, 10:23 am

You might also like