Clockwork Robot holding a red trending upward in steps arrow.
Python Trading Bot Image from Adobe Stock

Python Trading Bot

How to Calculate a 50-SMA on Binance with Python and Pandas

James Hinton
Geek Culture
Published in
3 min readNov 24, 2022

The 50-SMA is a super popular trading indicator for quantitative trading analysis. With the ongoing maturation of the general crypto market and the explosion of crypto trading bots, I thought it would be a great time to share how simple it is to calculate the SMA for yourself.

Using this article, you can easily plug the indicator into your trading bot. I’ll be using Python 3, Python Panda’s, and data from Binance. Links to these resources can be found at the bottom of the article.

Update August 2023

I could never have anticipated how popular this blog, along with a YouTube channel would become.

After a listening to my readers/viewers feedback, I realized that many people were spending huge amounts of time trying to solve installation/configuration problems — rather than experiencing the joy of algorithmic trading.

I want to change this narrative — and in so doing, open up algorithmic trading for everyone.

To do this, I’ve recently launched Tradeoxy: Trading For Everyone.

If you’re reading this, Tradeoxy will simplify 90% of this series, using a series of powerful API’s and easy to use tooling.

Currently it’s in the early-access / building stage and I’d be incredibly grateful if you’d join us on this adventure. Your feedback will help us shape a better product.

Join the early access program (for free) here.

You can also view our launch video, and follow our journey on LinkedIn, Twitter, Instagram, YouTube.

What is an SMA?

SMA is the acronym for a ‘Simple Moving Average’. It is the average price over a determined number of periods. The indicator is often used by traders to help predict trends in the market, with 50-day, 100-day, and 200-day indicators being the most common.

How to Calculate

The calculation for the 50-Day SMA is as follows:

Why It Might Be Useful

There are a number of common usages for an SMA, some of which I’ll cover in future…



James Hinton
Geek Culture

Passionate algorithmic trader and Cyber Security expert. Love developing helpful content.

Recommended from Medium


See more recommendations