Make an MACD + RSI + BB crypto trading bot with Coygo

Evan Francis
Coygo Blog
Published in
9 min readNov 30, 2022

Crypto day traders often rely on technical indicators to help confirm buy or sell signals. These technical indicators are calculated by running a specific algorithm over price/candlestick data to help determine trends and predict where prices may move next. For example, the Relative Strength Index (RSI) indicator is a popular choice to determine if an asset is oversold or overbought and trending towards a reversal.

While a single indicator will rarely provide enough information to be a reliable signal, multiple indicators can be combined to help provide a more in-depth understanding of how prices are trending.

If you’ve ever wanted to try automating your day trading uses technical indicators you’re in luck! In this post we will be creating a crypto trading bot that uses the MACD, RSI and Bollinger Bands (BB) indicators to attempt to find price reversals and quickly respond to them. We will do this using Coygo Bots, our incredibly powerful yet simple-to-use crypto trading bot platform.

If you’re interested in other automated crypto trading bot strategies Coygo Bots also has pre-built strategies for Crypto Swing Trading as well as Crypto Arbitrage! See our other blog posts for more details.

You can watch an overview discussing the details of this guide in our video below:

What is Coygo Bots?

Coygo Bots is our custom-built platform for creating and running crypto trading bots that help automate your crypto day trading. Coygo Bots was built with a focus on day trading specifically with the following core design philosophies:

  1. Real-time data and intervals as short as seconds or even milliseconds, making it perfect for day trading strategies like arbitrage, swing trading or scalping.
  2. Security: Your funds remain in your exchange accounts and your exchange account credentials (API keys) are only stored encrypted on your machine. Coygo’s servers never have access to your accounts. All trades are submitted directly from your machine to the exchange.
  3. Transparency is key to Coygo Bots. We offer a number of pre-built strategies, each with their JavaScript code completely open source for you to view or modify. There is no mysterious black box that you’re trusting with your trading.
  4. Customization: Not only are all pre-built strategies highly configurable and customizable, but you an also code your own custom strategy as well with JavaScript using Coygo Forge!

The Strategy: “Momentum reversal trader: MACD + RSI + BB”

This Strategy uses the MACD, RSI and Bollinger Bands technical indicators to attempt to find reversals and quickly react to them by purchasing the asset and configuring simultaneous stop-loss and take-profit conditions.

A chart displaying RSI, MACD and BB indicators

What are the MACD, RSI and BB indicators?

  • MACD (Moving Average Convergence Divergence), is a trend-following momentum indicator that can help identify and predict upwards or downwards trends in price. It compares the 26-period EMA (Exponential Moving Average) to a 12-period EMA. EMA is a moving average of the price that places a higher significance on more recent price changes than older price changes, helping to determine recent trends. When the MACD line crosses over to above the Signal Line this is sometimes referred to as a “bullish crossover” and is often considered a potential signal to buy.
  • RSI (Relative Strength Index) is a momentum indicator that looks at recent price movements to help determine if an asset is overbought or oversold. If an asset is overbought, a reversal downwards is possible (but not guaranteed). If an asset is oversold, a reversal upwards is possible.
  • BB (Bollinger Bands) Bollinger Bands are an indicator that uses a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the asset’s price. There are three lines: a basic moving average (the middle dark red line), and an upper and lower band (the green lines above and below). The are between the upper and lower band is highlighted with a light green background, creating the “band”. Many traders believe that the price will tend to stay within the band. So if you see the price nearing the lower band some believe that it’s probable the price will start moving back upwards to stay within the band, yielding a potential buy signal.

How does this strategy work?

The “Momentum reversal trader: MACD + RSI + BB” strategy submits an OTO (One-Triggers-Other) market order to buy when multiple buy signals are confirmed, which then triggers an OCO (One-Cancels-Other) order to submit two simultaneous orders for a sell limit order and a sell stop-market order. This allows the Strategy to create automatic stop-loss and take-profit conditions simultaneously.

Three buy signals must occur for the Strategy to confirm a buy condition:

  1. MACD — A bullish MACD crossover, where the MACD crosses over its signal line.
  2. RSI — The RSI must be below the “RSI buy Level” within the last X intervals, where X is the “RSI look back period”.
  3. Bollinger Bands — The price must be close enough to the lower band within the last X intervals, where X is the “Bollinger Bands look back period”. This is configured using the Bolling Bands %B value which denotes how close the price is to the upper and lower bands. See the “Bollinger Bands %B Explanation” below for more details.

NOTE: The “Execution interval” for this Bot is the interval used to calculate each technical indicator. You will probably want to use an “Execution interval” of 1 minute or higher as momentum indicators like MACD may not provide valuable information on very short intervals.

Bollinger Bands %B Explanation

The Bollinger Bands %B value quantifies the price relative to the upper and lower Bollinger Bands.

  • When the price is below the lower band, %B < 0
  • When the price is at the lower band, %B = 0
  • When the price is between the lower and middle band (an SMA) %B is between 0 and 0.5
  • When the price is at the middle band, %B = 0.5
  • When the price is between the middle and upper band (an SMA) %B is between and 0.5 and 1.
  • When the price is at the upper band %B = 1.
  • When the price is above the uper band %B > 1.

How to create an MACD + RSI + Bollinger Bands crypto trading bot with Coygo Bots

1. Sign in to Coygo Terminal

The Coygo Bots platform is available within Coygo Terminal, a downloadable desktop application for macOS, Windows and Linux. First you will need to sign in to Coygo Terminal. If you don’t have an account, you can start a free trial today! Learn more on our pricing page.

Coygo Terminal

2. Go to “My Strategies” to select the “Momentum reversal trader: MACD + RSI + BB” Strategy

Within Coygo Bots you can use the “My Strategies” page to see a list of every trading bot strategy that you can use. Here you will find “Momentum reversal trader: MACD + RSI + BB” Strategy. You can click the “+ Create Bot” button on this strategy to create a new trading bot!

Create a new trading bot

3. Configure your trading bot

After selecting the Strategy you are shown a “Configure” screen that allows you to select your desired preferences. Each Strategy will have a different “Configure” screen specific to that Strategy. It’s up to you to decide which exchange and trade pair to use, as well as your buy trigger is, stop-loss, and other configurations. Each option has a descriptive label to explain how it will be used by the Bot. Please see the video at the top of this post if you want a walk-through of each configuration property.

(Don’t worry — you can run your trading bots in Test Mode a.k.a. “paper trading” to try different configurations without using real money or submitting real orders.)

The most important configuration options are the following:

Execution interval

  • This is the interval at which this bot executes. Once per interval the bot will re-asses market data and submit/manage orders if appropriate. This is the interval used to calculate the MACD, RSI and BB indicators.
  • You will probably want to use an “Execution interval” of 1 minute or higher as momentum indicators like MACD may not provide valuable information on very short intervals.

RSI buy level

  • The RSI value that is considered a buy signal. Defaults to 35.

RSI look back period

  • If the RSI value drops below the “RSI buy level” within this number of intervals defined by “RSI look back period”, it is considered a buy signal

Bollinger Bands %B buy level

  • Defines how close the price must be to the lower Bollinger Band value to be considered a potential buy signal. Setting this to zero would mean that the price touching the lower band is a potential buy signal. (See the %B explanation in this Strategy’s description for more info)

Bollinger Bands look back period

  • If the Bollinger Band %B value drops below the “Bollinger Bands %B buy level” within this number of intervals defined by “Bollinger Bands look back period”, it is considered a buy signal

Take profit %

  • The desired profit % used for configuring sell prices. When a buy order is filled an accompanying sell order will be opened at the ask rate at the time of parent order submission + “Take profit %”.

Stop-loss %

  • If the Bot has entered a position by buying an asset, and then the asset’s price drops by >= this percent, the Bot will sell the position to prevent further losses.
Configure your “Momentum reversal” bot

4. Run your new trading bot!

Now that you’ve created and configured your trading bot it’s time to try running it on the “Run” screen for this Bot. You can choose how long you want it to run (or indefinitely if you so choose), and you can enable Test Mode if you want the bot to simulate trades. If using Test Mode you can specify any fake wallet balances you want the Bot to use.

Run your new trading bot

5. Monitor your running trading bot

While your trading bot is running it will keep you informed with real-time data about the bot’s decision making and orders submitted.

You can use the Activity Log on the left in to see a descriptive explanation of what the bot is doing and any decisions it’s making during each interval of execution. For this Strategy you will see how the bot is calculating each indicator (MACD, RSI, BB) and if/when a buy signal occurs.

The Activity Log will default to showing the latest data but you can always go back in time and view previous intervals to get an understanding of exactly what your trading bot is doing over time.

Running bot

6. Stop your trading bot

When you started to run your trading bot you chose a maximum run time, perhaps 4 or 8 hours. When this amount of time has completed the bot will stop itself. You can also click the “Stop This Bot” button at any time while the bot is running to immediately stop it as well.

Try Coygo for free today!

If you’d like to try Coygo Bots you can start a free trial today. We would love to hear your feedback! We want to make sure we’re providing the best possible solution for you.

Follow us on social media and subscribe to our blog to keep up to date with Coygo’s progress as we continue to develop the best tools for cryptocurrency and digital asset traders.

YouTube: https://www.youtube.com/@coygo

Twitter: https://twitter.com/CoygoHQ

Facebook: https://www.facebook.com/CoygoHQ/

LinkedIn: https://www.linkedin.com/company/coygo

--

--

Evan Francis
Coygo Blog

CEO and Co-founder of Coygo, Inc. and Lunafi, LLC, cryptocurrency enthusiast, software engineer, alpine skier