Expert Advisors and Algo Trading Basics
By Chad Smith, Director of Research & Analysis · Updated
On this page
In this lesson you will learn
- Explain what Expert Advisors, cBots and trading algorithms do
- Describe the steps from idea to live automated strategy
- Recognize curve fitting and other backtesting traps
- Evaluate bought or downloaded EAs with healthy skepticism
The charting lesson showed how to set up charts for your own analysis. This lesson looks at letting software do some of the work. You will learn what Expert Advisors and other trading algorithms are, the steps from an idea to a live automated strategy, the traps in backtesting, and how to judge an EA that someone else built.
What algo trading means
Algorithmic, or algo, trading means using a computer program to follow trading rules. The program can:
- watch prices and indicators
- decide when a setup appears
- place, manage and close orders
- apply risk rules such as size and maximum loss
On MetaTrader, these programs are called Expert Advisors (EAs) and are written in MQL4 or MQL5. On cTrader, they are cBots, written in C#. On TradingView, Pine Script strategies are mainly used for testing, with live execution needing extra connections. Some traders also use general programming languages, such as Python, connected to a broker through an API.
Algo trading ranges from simple helpers, such as a script that sets stops automatically, to fully automated strategies that trade without any human input.
Why traders automate
- Consistency. A program follows its rules every time, without fear or greed.
- Speed. It reacts faster than a person.
- Coverage. It can watch many markets and hours at once.
- Testing. Clear rules can be tested on historical data.
Automation does not make a strategy profitable. It simply carries out the rules. A losing set of rules, automated, loses faster and more consistently.
From idea to live strategy
A careful process looks like this:
- Write the rules in plain words. Entry, exit, stop, target, size and when not to trade. If you cannot write them clearly, they cannot be coded.
- Code the strategy or have it coded.
- Backtest it on historical data. Backtesting shows how the rules would have behaved in the past.
- Test on out-of-sample data, a period the strategy was not designed on.
- Forward test on demo for a set period, with live prices and execution.
- Go live with small size, and compare results with the demo and backtest.
- Monitor and review regularly, with a rule for when to switch it off.
Backtesting traps
Backtests can be misleading. The main traps:
Curve fitting (over-optimization). If you adjust settings again and again until the backtest looks perfect, the strategy may only fit the past. It learned the noise in that data, not a lasting pattern. A sign of curve fitting is a strategy that works only with very specific settings and fails when they change slightly.
Unrealistic costs. A backtest that uses a fixed small spread, no commission and no slippage will look better than live trading. This matters most for short-term strategies such as scalping.
Poor data quality. Missing data or low-detail data can give false results, especially for strategies that use small stops.
Look-ahead bias. A coding error that lets the strategy use information it would not have had at the time.
Too few trades. A backtest with a handful of trades says little.
Worked example (illustrative numbers): a scalping EA's backtest assumes a spread of 0.5 pips and shows an average profit of 1.5 pips per trade. In live trading, the average spread is 1.0 pip and slippage adds 0.3 pips. The average profit per trade falls from 1.5 to 0.7 pips, more than half the edge, before commission. The cost of trade calculator helps you include real costs.
Reading a backtest report
Look beyond total profit. Useful figures include:
- number of trades
- maximum drawdown, the largest fall from a peak
- average win and average loss
- win rate
- longest losing streak
- how results change across different years or market conditions
A strategy with a smooth result but a very large maximum drawdown may be harder to live with than the profit figure suggests.
Buying or downloading EAs
Many EAs are sold or shared online. Some are honest tools; many are not. Healthy skepticism helps:
- Be wary of perfect backtests. A smooth upward line with almost no losses is often a sign of curve fitting.
- Check for risky money management. A martingale system, which increases size after each loss, can show many small wins and then a very large loss. Grid systems that add positions without a stop carry similar risks.
- Ask for a verified live record, not only a backtest or screenshots. The signals course explains how verification works.
- Understand the logic. If the seller cannot explain how it trades, you cannot judge when it might fail.
- Avoid promises of guaranteed returns. No honest seller can guarantee results.
Running an EA
Expert Advisors run on your device. If the computer sleeps, loses internet or shuts down, the EA stops managing trades. Many traders use a virtual private server so the EA can run all the time. Also check:
- that automated trading is allowed on your account and by your broker
- that the platform's "Algo Trading" or "AutoTrading" button is enabled
- that the EA is set for the correct symbol, timeframe and size
Key takeaways
- Algo trading uses programs, such as EAs and cBots, to follow trading rules automatically.
- Automation gives consistency and speed but does not create an edge.
- Move from plain-word rules to backtest, out-of-sample test, demo forward test and small live size.
- Watch for curve fitting, unrealistic costs and too few trades in backtests.
- Be skeptical of bought EAs with perfect backtests, martingale logic or no verified live record.
Check your understanding
1. What is curve fitting?
- A. Drawing a trendline
- B. Tuning a strategy so closely to past data that it fails on new data
- C. A type of order
- D. Using a curved moving average
Show answer
B. Tuning a strategy so closely to past data that it fails on new data
2. Why should a strategy be forward tested on demo after backtesting?
- A. To see how it behaves on new, unseen data with real execution conditions
- B. Because backtests are always wrong
- C. To lower the spread
- D. It is not useful
Show answer
A. To see how it behaves on new, unseen data with real execution conditions
3. Which EA feature is a warning sign?
- A. A clear stop-loss on every trade
- B. A martingale system that doubles size after each loss
- C. Settings you can adjust
- D. A detailed manual
Show answer
B. A martingale system that doubles size after each loss
Where to practice this
Put this into practice on a demo account first, with no money at risk.
- Featured broker
Pepperstone4.7 / 5Visit
IC Markets4.9 / 5Visit
GO Markets4.8 / 5Visit