Module 5 — Algorithmic trading · Lesson 19 of 23 · 6 min

Introduction to algorithmic trading: what it is, what it promises and what it really requires

What algorithmic trading is, the strategy families, the pipeline from data to order, the tools, where to find historical data, the limits, the regulatory aspects and a roadmap.

In the previous modules you learned to describe the market with precise rules. Algorithmic trading takes the next step: writing those rules in a program that applies them identically, without emotion, over thousands of cases. It isn't a way to "earn more without effort": it's a tool to verify and, if the system has an edge, to execute consistently. This lesson gives you the overview, before the code.

What it is (and what it isn't)

Algorithmic trading consists of defining exact entry, exit and risk management rules and having software execute them. There are two levels, often confused:

  • Algorithmic research: using code to test hypotheses on historical data (backtesting). Very accessible, very instructive.
  • Algorithmic execution: having orders placed automatically on an account (demo or live). It requires infrastructure, monitoring and security.

The main advantage is not "earning more": it's (1) consistency (the algorithm has neither fear nor greed), (2) the ability to test on years of data in minutes and (3) control of costs and risk. But the algorithm doesn't create an edge out of nothing: if the rules have no edge, it will lose in a perfectly consistent way.

The strategy families

FamilyIdeaNotes
Trend followingFollow the move (moving averages, breakouts, momentum)Many small stops, few big wins
Mean reversionBet on a return to the mean after an excessHigh frequency, risk in strong trends
Volatility breakoutEntries on the break of a rangeFrequent false breakouts
Structure-based (SMC/ICT)Coded sweeps, MSS, FVG, order blocksRequire objective definitions (the theme of this module)
Arbitrage / market makingExploit price inefficienciesRequire infrastructure and costs retail doesn't have

The pipeline: from data to order

  1. Data: clean historical candles, with a consistent time zone and no gaps.
  2. Features: indicators and structures (ATR, swings, FVG, sweeps, sessions).
  3. Signals: rules that say "enter long/short".
  4. Backtest: simulation with costs, management, stops and targets.
  5. Validation: statistics, out-of-sample, walk-forward, Monte Carlo.
  6. Paper trading: same logic, real-time data, virtual money.
  7. Live execution with safety limits and monitoring.

Each step can introduce errors. That's why module 4 (validation) comes first: without honest tests, an algorithm is just a fast way to be wrong.

Tools to start

  • Python with pandas and numpy: the standard for analysis and backtesting. You can install it for free and use Jupyter or VS Code.
  • MetaTrader 5: a retail platform that supports Expert Advisors in MQL5 and has an official Python library to read data and place orders (works on Windows).
  • TradingView with Pine Script: great for prototyping indicators and strategies and visualising results.
  • A research notebook (Jupyter) and Git to version code: versions matter when you change the rules.

Where to find historical data

  • Your broker's data (export from MT5): consistent with what you'll execute, but often limited in time.
  • Free providers of historical forex candles (for example public tick- or minute-level archives): always check time zone, sessions and gaps.
  • APIs with free plans for recent intraday data.

Whatever the source, check: time zone, weekend gaps, missing candles, duplicates, price quality (bid vs. ask data change the implicit spread). An error in the data produces useless results.

A first example: the pipeline in miniature

A minimal pandas example, just to see the flow (a simple moving average, not a recommended strategy):

import pandas as pd

df = pd.read_csv("eurusd_h1.csv", parse_dates=["time"]).set_index("time")
df["ema_fast"] = df["close"].ewm(span=20, adjust=False).mean()
df["ema_slow"] = df["close"].ewm(span=50, adjust=False).mean()

# Signal: 1 if the fast average is above the slow one, 0 otherwise.
# The value of the PREVIOUS candle is used (shift) so as not to look into the future.
df["signal"] = (df["ema_fast"] > df["ema_slow"]).astype(int).shift(1)

# Candle return if in position (before costs)
df["ret"] = df["close"].pct_change() * df["signal"]
print(df["ret"].sum())

Note the detail shift(1): a signal calculated at the close of candle t can only be used from candle t+1. Forgetting it is the most frequent error and produces "fantastic" and false backtests.

Limits and risks

  • A badly written algorithm loses consistently. A bug that opens repeated positions can destroy an account in minutes.
  • The backtest deceives: overfitting, look-ahead and underestimated costs are the main risks.
  • Markets change: rules that worked can stop working.
  • Maintenance is needed: data, connections, broker updates.
  • The retail edge is small: don't expect spectacular returns.

Regulatory aspects (briefly)

Automating your own account is allowed. If in the future you wanted to sell an algorithm, offer paid signals, manage other people's money or provide advice, authorisation requirements may apply (for example in the EU and UK): get professional advice beforehand. Also check your broker's terms on automated trading and the tax rules of your country.

A roadmap

  1. Learn the basics of Python and pandas (a week of practice).
  2. Code the features (ATR, swings, FVG, sweeps): lesson 3 of this module.
  3. Build the backtest with costs and statistics: lesson 4.
  4. Validate (out-of-sample, walk-forward, Monte Carlo).
  5. Paper trading for weeks.
  6. Live with minimum size and safety limits: lesson 5.

In short

  • Algorithmic trading serves to test and execute rules consistently, not to create an edge out of nothing.
  • Pipeline: data → features → signals → backtest → validation → paper → live.
  • Python (pandas/numpy) for research; MT5/MQL5 for execution; TradingView/Pine for prototypes.
  • Take care of the data (time zone, gaps) and always use shift to avoid look-ahead.
  • The main risks: bugs, overfitting, underestimated costs, regime changes; check the regulatory aspects.

Practical exercise

  1. Install Python and pandas and load a candle file into a notebook.
  2. Calculate the 14-period ATR and plot a chart.
  3. Reproduce the moving average example with and without shift(1): compare the results and explain the difference.

Test what you've learned

1. What is the main advantage of an algorithm?

2. Why is shift(1) used in signals?

3. What do you check in historical data?

4. When may authorisation be needed?

Have a question or want to share your exercise?

Post in the community, or join the free signals room on Telegram.

Educational content, not financial advice. Trading involves risk. ICT is a term referring to the materials of Michael Huddleston: this course is independent and not affiliated.