Quant Science Profile picture
Jun 29, 2025 9 tweets 3 min read Read on X
How to use MACD for algorithmic trading Machine Learning.

Let's dive in. 🧵 Image
MACD (Moving Average Convergence Divergence) is most commonly used in Technical Trading.

But, it can be used as part of a factor model.

Let's see how. Image
1. What is MACD?

MACD is a trend-following momentum indicator that shows the relationship between two moving averages of a security's price.

The MACD is calculated by subtracting the long-term exponential moving average (EMA) from the short-term EMA.
2. Components of MACD:

MACD Line: This is calculated by subtracting the 26-period EMA from the 12-period EMA.

Signal Line: This is a 9-period EMA of the MACD Line itself.

MACD Histogram: This is the difference between the MACD line and the Signal line. Image
3. How MACD is used:

The primary method is to look for crossovers between the MACD line and the signal line.

When the MACD line crosses above the signal line, it is a bullish signal.

Conversely, when the MACD line crosses below the signal line, it is a bearish signal. Image
4. Factor model with MACD

We can add MACD as features.

These features power our Machine Learning models.

And allow us to predict: 1D, 5D, 10D, and 21D returns forecasts. Image
🚨 NEW WORKSHOP: How I built an automated algorithmic trading system with Python.

Hedge funds have better tools & faster execution.

That ends on July 9th.

👉 Register here to learn how to compete in an unfair game with Python (500 seats): learn.quantscience.io/become-a-pro-q…Image
That's a wrap! Over the next 24 days, I'm sharing my top 24 algorithmic trading concepts to help you get started.

If you enjoyed this thread:

1. Follow me @quantscience_ for more of these
2. RT the tweet below to share this thread with your audience
P.S. - Want to learn Algorithmic Trading Strategies that actually work?

I'm hosting a live workshop. Join here: learn.quantscience.io/qs-register

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Quant Science

Quant Science Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @quantscience_

Feb 12
No one made more money in trading than Jim Simons.

Not Buffett. Not Soros. Not Dalio.

His hedge fund was so powerful that he shut it down to outsiders.

$100 in 1988 grew to $400M in 30 years.

Here’s how a mathematician became the world’s greatest trader: Image
Jim Simons was no ordinary investor.

Before conquering Wall Street, he was:

• A math professor at MIT and Harvard
• A Cold War code-breaker for the NSA
• A pioneer in quantum computing

But none of this satisfied him.

"Some people like to paint, others like to cook. I like to make money."Image
At 40 years old, Simons left his prestigious academic career to start a hedge fund.

He had no finance experience. No Wall Street background.

His secret weapon? Mathematics. Image
Read 17 tweets
Feb 10
A strategy with a Sharpe of 0.94 (and 513.8% cumulative return): Image
A strategy only Goldman Sachs can trade?

Nope.

It's a VIX-based futures strategy that demolishes the benchmark just like the pros.

Here's how:
SigTech.

Here's a primer in case you're unfamiliar with SigTech:

• Quant tech for institutional investors
• Provides data and tools to hedge funds
• Customers with $5 trillion in assets under management

SigTech was built for institutions. Now you can have it too:
Read 14 tweets
Feb 6
How to make your own algorithmic trading system in Python (a complete roadmap): Image
Step 1: Learn Python

- Pandas: Data Analysis
- Scikit Learn: Machine Learning
- SQLAlchemy: Databases
Step 2: Set up your financial database

Financial Data:
- Price: Yahoo Finance (free)
- Fundamentals: Financial Modeling Prep (paid)

Database:
- DuckDB (free) Image
Read 10 tweets
Feb 2
Automate your trading strategies in Python

How to build your first trading bot:

(a thread) Image
1. What is a trading bot?

A trading bot is a software program that automates buying and selling financial assets like stocks and cryptocurrencies based on pre-defined strategies and rules.

These automated systems can manage portfolios without human intervention, operating 24/7.
2. Let's make a Bitcoin Trading bot

We'll use investing-algorithm-framework in Python Image
Read 12 tweets
Feb 1
How to make a simple algorithmic trading strategy with a 472% return using Python.

A thread. 🧵 Image
This strategy takes advantage of "flow effects", which is how certain points in time influence the value of an asset.

This strategy uses a simple temporal shift to determine when trades should exit relative to their entry for monthly boundary conditions. Image
The signals for when to go short, when to cover shorts, when to go long, and when to close longs are all linked to these recurring monthly cycles.

This periodic "flow" of signals—month-in, month-out—creates a systematic pattern. Image
Read 11 tweets
Feb 1
12 Python libraries for free market data everyone should know: Image
yfinance

Data for stocks (historic, intraday, fundamental), FX, crypto, and options. Uses Yahoo Finance so any data available through Yahoo is available through yfinance.

github.com/ranaroussi/yfi…
pandas-datareader

pandas-datareader used to be part of the pandas project. Now an independent project. Includes data for stocks, FX, economic indicators, Fama-French factors, and many others.

pandas-datareader.readthedocs.io/en/latest/
Read 17 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(