Creating a Winning Strategy with Bollinger Bands and Psychological Levels
Written on
Chapter 1: Introduction to the Strategy
Combining different trading techniques often leads to a more resilient approach. In this discussion, we will merge the well-known Bollinger Bands with the concept of Psychological Levels to devise a trading strategy.
I’ve published a new book following the success of my previous work, "Trend Following Strategies in Python." This latest release includes advanced contrarian indicators and strategies, complemented by a GitHub repository for ongoing code updates. If you're interested, you can purchase the PDF version for 9.99 EUR via PayPal. Please ensure to include your email in the note to receive the document directly, and remember to download it from Google Drive.
Chapter 2: Understanding Bollinger Bands
Bollinger Bands are built on two main statistical concepts: averages and volatility. Averages help predict future values based on historical data, while volatility indicates how much individual data points deviate from their average.
For example, if we have a series of numbers like {5, 10, 15, 5, 10}, the average can be calculated as follows:
# Importing the required library
import numpy as np
# Creating the array
array = [5, 10, 15, 5, 10]
array = np.array(array)
# Calculating the mean
mean_value = array.mean()
In this case, the average is 9. However, to understand how dispersed the data points are, we also need to calculate the Standard Deviation (Volatility):
# Calculating the standard deviation
std_dev = array.std()
This tells us that on average, the data points are approximately 3.74 units away from the mean of 9.
Now, let’s delve into the Normal Distribution curve, which visually represents data dispersion. For normally distributed data:
- About 68% falls within one standard deviation from the mean.
- About 95% falls within two standard deviations.
- About 99% is contained within three standard deviations.
Although financial data often deviates from normal distribution, these concepts can still be applied to analyze market behavior.
Chapter 3: Implementing the Bollinger Bands Indicator
The Bollinger Bands indicator utilizes a moving average to assess price positioning relative to its average. This is achieved by calculating two bands that represent standard deviations from the moving average.
To create the Bollinger Bands, we follow a straightforward formula involving a moving average and standard deviations:
# Example of calculating Bollinger Bands
def BollingerBands(Data, boll_lookback, standard_distance):
# Calculate mean
ma(Data, boll_lookback)
# Calculate volatility
volatility(Data, boll_lookback)
Data[:, upper_band_col] = Data[:, mean_col] + (standard_distance * Data[:, volatility_col])
Data[:, lower_band_col] = Data[:, mean_col] - (standard_distance * Data[:, volatility_col])
return Data
The above approach informs trading decisions. For example, when the EUR/USD reaches the upper band, it may indicate consolidation, while touching the lower band suggests a potential bounce.
Video Description: Learn how to effectively utilize RSI and Bollinger Bands for maximizing your trading profits with this comprehensive tutorial.
Chapter 4: Psychological Levels in Trading
Psychological levels are critical in trading as they often attract more market attention compared to other price points. Round numbers, such as 1.1500 on the EUR/USD, are frequently regarded as psychological benchmarks.
Our goal is to create an algorithm that triggers trades whenever the market approaches these psychological levels. This can be accomplished through a simple loop function in Python.
def psychological_levels_scanner(data, close, position):
level = 0
for i in range(len(data)):
if data[i, close] == level:
data[i, position] = 1level = round(level + 0.01, 2)
if level > 5:
breakreturn data
The above code identifies key psychological levels, which can serve as advantageous trading signals.
Video Description: Discover the truth behind the Bollinger Bands and RSI strategy in this revealing video, and learn how to apply it to your trading.
Chapter 5: Combining the Strategies
To visualize the effectiveness of our combined strategy, we establish the following conditions:
- Enter a long position when the market is at or below the lower Bollinger Band and simultaneously at a psychological level.
- Enter a short position when the market is at or above the upper Bollinger Band and also at a psychological level.
def signal(Data):
for i in range(len(Data)):
if Data[i, close_price_col] <= Data[i, lower_bollinger_col] and Data[i, psychological_level_col] == 1:
Data[i, buy_signal_col] = 1elif Data[i, close_price_col] >= Data[i, upper_bollinger_col] and Data[i, psychological_level_col] == 1:
Data[i, sell_signal_col] = -1return Data
This strategy enhances decision-making by combining the insights offered by Bollinger Bands with the significance of psychological levels.
Chapter 6: Conclusion
In summary, my objective is to contribute to the field of technical analysis by promoting transparent, objective strategies that undergo thorough back-testing before real-world application.
When exploring trading techniques, I recommend the following steps:
- Maintain a critical mindset devoid of emotional influence.
- Back-test using realistic simulations.
- Optimize and conduct forward tests if potential is identified.
- Always account for transaction costs and slippage.
- Incorporate risk management and position sizing.
Stay vigilant, as market dynamics can shift, rendering previously successful strategies ineffective.