Build Your Own Trading Bot by AppnologyJames
Step-by-Step Guide to Add Bollinger Bands™️ to Your Trading Bot with Python, Alpaca Markets and TA Lib

The Bollinger Bands technical indicator is a technical indicator that is widely used to calculate the movements of financial assets. Adding it to your trading bot can be a powerful way to analyze crypto, forex, and stock data patterns and use the insights you gain to level up your trading strategies.
In this episode, I’ll show you how to add the Bollinger Bands technical indicator to your trading bot and customize it for your trading bot strategies.
About This Episode
In this episode, I’ll show you how to add the Bollinger Bands Technical Indicator to your trading bot. While I’ve specifically mentioned stock trading in the title, you can use this same technical indicator on any capital market you want to automate trading for, including Crypto, Forex, and more.
What You’ll Need to Complete This Episode
- 15 minutes. Including your code writing, development, and a bit of fun testing, this episode will take a beginner Python developer around 15 minutes to complete.
- Beginner knowledge of Python Programming. The code is pitched at those who are at the beginner to intermediate level of Python development.
- Dev environment. You can check out my article, “Build Your Own Trading Bot Development Environment” if you want an AI supercharged, available anywhere development environment.
- Market data. You’ll need some market data to analyze. If you want to get some stock data, check out my article “Step-by-Step Guide to Get Any US Stock Price Data with Python and Alpaca Markets”
Level Up Your Learning Experience with TradeOxy’s Free Support
I’m a huge believer in creating exceptional learning experiences for people. Education changes everything! Built right into the DNA of my company is a culture of helping those who are investing in their learning. Here are the resources we’ve built so far:
- Open Source TradeOxy Trading Bot. All of the code I’ll show you comes from the TradeOxy Trading Bot. This trading bot is completely open source, and you are welcome to use it — just give us credit when you do 🙂
- Discord Help Channel. If you’ve got any questions about the content, reach out to us on our Discord Channel. We’ll reply as soon as we can, and our community is pretty helpful as well.
- YouTube Channel. If you prefer video content to written content, check out my YouTube channel.
Legal Stuff
- DYOR. Note that all trading is at your own risk. My goal is to provide you with the self-developed methods, systems, and tools I use — it is up to you to figure out if this solution works for you AND if I’ve provided credible content. Always DYOR (Do Your Own Research).
- Not Financial Advice. At no point should you consider anything in these articles to be financial advice. Any opinions expressed are about the technical aspects of the topic, not financial suitability.
- Referrals. I receive no commissions for any of the products I mention in this blog. They’re all free (or have a free tier), and I simply provide links to simplify your learning experience.
- AI Use. No AI was harmed in the creation of this blog. Some of the images are partially generated or enhanced through AI tools, we always use a real human to put them together. I do not use AI to generate the text, just spell check.
How to Set up Your Trading Bot for Indicators
Algorithmic trading relies on analysis to inform decision-making. Almost always, this means adding some kind of indicator.
The thing about indicators and trading bots is that they tend to breed. The more you analyze data, the more likely it is that you’ll have more and more indicators you want to add to your trading bot.
A common way to manage this complexity is by building your own indicator library
In this library, you can add any indicator you choose.
- Bollinger Bands✅
- Other indicators from TradeOxy ✅
- Indicators from other content creators✅
It’s a powerful way to simplify much of your future autotrading development 🚀🚀🚀
Add an indicators.py file
If you haven’t done this in a previous episode, add the indicators.py file to your trading bot. This file will handle anything to do with indicators in the rest of your TradeOxy Trading Bot development.
Get the Python Pandas Library
The Python Pandas Library is considered a gold standard in data analysis. It’s transcended the into the ranks of mythical status in Python and is widely used in an incredible set of industries.
Adding this exceptionally powerful analysis tool to your trading is as simple as 4 steps:
- Navigate to
requirements.txt - Add the word
pandasto the bottom - Save
- Run
pip install -r requirements.txt
Here’s what your should look like if you used my dev environment episode to get started:

Dynamic Indicator Selection
To prepare for a multi-indicator future for your trading bot, we’re going to add some routing to your indicators.py file. This routing allows you to simply specify the indicator you want to use at any stage of your algorithm by using normal human language.
Add this code to your indicators.py (note that we’ll be adding in the Bollinger Bands technical indicator in the next section):





