Implementing a Support/Resistance Breakout Strategy (Python Tutorial)
Sometimes an explosive upward trend breakout shatters the roof of a resistance level and takes the price to new heights. These are the types of major price movements that can be very profitable for traders.
In this post we are going to discuss what support and resistance are, how the resistance breakout strategy works and how it can be implemented step-by-step in Python.
This story is solely for general information purposes, and should not be relied upon for trading recommendations or financial advice. Source code and information is provided for educational purposes only, and should not be relied upon to make an investment decision. Please review my full cautionary guidance before continuing.
What are Support/Resistance and Breakout?
Support and resistance are concepts in technical analysis for trading that help us determine where a price may stop and reverse the current direction. They exist due to an accumulation or demand and supply at these price levels.
Support
A level of support is created when the price fall is stopped due to an increasing level of demand for the asset and consequently the price trend is reversed. If this event occurs multiple times, a level of support is assumed.
Resistance
In opposite, a level of resistance is created when the rise of a price is stopped due to an increasing level of supply. As more and more people are selling the asset due to an attractive price, the price trend is reversed and the price starts falling again. If this happens multiple times, the price level is called a level of resistance.
Breakout
A breakout occurs at times when overwhelming supply or demand causes the price to break through a level of support or resistance and continues to move in the same direction.
For example, as company A’s price is at the price level of resistance, the company’s earnings are published and surprisingly beat analyst’s estimates. As a consequence positive news coverage increases, more investors buy the stock and the overwhelming demand drives the price through the previous level of resistance.
These are the type of events we are going to leverage as a trading strategy in this post.
Of course a breakout can also occur when the price continues falling at a level of support.
Trade Ideas provides AI stock suggestions, AI alerts, scanning, automated trading, real-time stock market data, charting, educational resources, and more. Get a 15% discount with promo code ‘BOTRADING15’.
The Strategy
For this strategy we are going to use two concepts: Agglomerative Clustering, which I covered in this post and the Average Directional Index (ADX), which I discussed in this post. If you are not familiar with these subjects, I suggest you read those posts first.
Here’s the plan for the ‘Resistance Breakout’ Strategy:
Long Entry:
First, we need to determine the levels of support and resistance for a range of dates.
When find events when the price rises to a level of resistance and breaks through that level.
At the same time we will use the ADX indicator to determine the strength of the trend. We will check for a value of 25. This is to prevent that a weak price trend ends in a failed breakout.
We will also check the ADX positive (+DI) and negative (-DI) indicators for the price direction. In this case the +DI has to be above the -DI.
Long Exit
In this strategy we are only interest in exploiting that first, explosive upward trend after the breakout. So as an exit strategy, I’m just going to use a trailing stop loss and stop loss combination.
Trailing stop loss of 1%
Stop loss of 5%.