Algorithmic trading — first steps for a retail trader
Retail algorithmic trading is a simple swap of roles: the trader defines the rule, the computer executes it. "If the fast moving average crosses above the slow one and the ATR of the last twenty bars is rising, open a long sized at 1 percent of capital, set the stop 1.5 ATR below." That, in essence, is the whole definition. Everything else — VPS providers, languages, frameworks — is scaffolding. The trouble with most retail algo projects is not the code but the assumption that automation can compensate for an edge the trader does not actually have. It cannot. It will only lose faster and cheaper than the human did.
What algo trading is and definitely is not
An algorithm is two things in one: a precisely defined strategy and the mechanism that fires it without emotional flinching. A trader who can write down a complete set of entry, exit, position-sizing and loss-management conditions in unambiguous language has done half the work; the rest is translating that document into MQL5, Python or a plain alert. A trader who lacks that discipline starts by learning syntax and only later discovers there is nothing concrete to code. Every reasonable book on systematic trading repeats the same advice — operationalise the strategy by hand first, automate it second — and every weekend course selling "a bot for one hundred and ninety-nine dollars" ignores it. Algo is also not a magical source of passive income: a strategy that works today works because a particular market regularity still holds, and the moment it disappears the bot loses just as effectively as a discretionary trader, only without the emotional warning that something is off.
The ladder from alerts to full automation
The natural path runs through four rungs. The first is platform alerts in TradingView or MetaTrader that fire a sound or an email when the entry condition is met. The trader still clicks the order, but is forced to translate the strategy into a rule precise enough that the platform can express it. Many retail traders never leave this rung and do not need to — alerts plus discipline are enough when the number of signals per day is small. The second rung is a simple Expert Advisor in MQL5 for MetaTrader, usually a moving-average crossover with a trailing stop or an ATR breakout. Such an EA runs to two or four hundred lines and is built in weeks; we cover the language in MQL5 expert advisor basics. The third rung is a Python backtester with pandas, NumPy and backtrader; here the trader iterates dozens of strategy variants in a single evening — unpacked in Forex backtesting in Python. The fourth and optional rung is a direct broker connection through REST or FIX with Interactive Brokers or OANDA, retiring MetaTrader as the intermediary layer.
Skills and the language choice
The list is short. Statistical thinking matters most — grasping the difference between win rate, profit factor and expectancy, and knowing that a fifty-trade equity curve proves nothing yet. Without it, even clean code produces conclusions of the form "the strategy works because the last six trades were winners", which is a null hypothesis rather than analysis. Second comes patience for the validation cycle: idea, coding, backtest, walk-forward, three to six months on demo, and only then real capital. Third are the programming basics — variables, loops, functions, a pandas DataFrame. You do not need to be a software engineer; being able to read someone else\'s EA and change a parameter without breaking the rest is enough. The language choice hinges on one thing: does the trader stay inside MetaTrader, or leave it? MQL5 is the native language of MT5, execution latency is measured in single-digit milliseconds, and Strategy Tester delivers a respectable backtest out of the box. Python is the entire world beyond MetaTrader — pandas and NumPy for crunching data, backtrader or vectorbt for backtests, REST clients for Interactive Brokers and OANDA. The trade-offs are unpacked in trading bot — MQL5 versus Python.
An illustrative example — first strategy from concept to backtest
Take a crossover strategy on EUR/USD on H1: open long when the EMA 21 crosses the SMA 55 from below, provided the ATR of the last fourteen bars is above its fifty-period mean. Stop 1.5 ATR below entry, take profit 2.5 ATR above, position size 1 percent of capital. Step one: the trader executes forty entries manually in MT5 on the recent six months of data, computes the win rate and the average winning and losing trade. Suppose the result is 38 percent win rate with profit factor 1.4. Step two: code the EA in MQL5 and run it through Strategy Tester across five years of history. The result should converge on the manual figures, or differ systematically — in the latter case the trader knows that either the rule was written down incorrectly or some part of the manual execution was being interpreted intuitively. Step three: the same EA tested in Python with backtrader on Dukascopy data, including realistic spread and slippage. Step four: walk-forward, if the numbers are stable. All figures are illustrative — they show the sequence, not a promise.
“The biggest enemy of an algorithmic trader is data-snooping bias. Models that look great in backtest often fail in live trading not because the strategy is wrong, but because the trader optimised it on the same data they used to evaluate it.” — Ernest P. Chan, Algorithmic Trading: Winning Strategies and Their Rationale, Wiley, 2013
Why most retail algo projects fail
The reasons are two and neither has anything to do with programming skill. The first is the absence of a market edge worth automating — the trader writes a backtester, fits parameters to the last five years of data and ends up with an equity curve more beautiful than reality could ever produce. They go live, lose money, conclude they need "a better strategy" and repeat the loop. How to isolate and validate an edge before the first line of code is written is unpacked in the piece on trading edge discovery. The second reason is unwillingness to accept "your strategy has no edge, go back to the drawing board". Most traders prefer to over-optimise the parameters rather than hear it — the algorithm will not soften the message, only repeat it faster. On the infrastructure side, reality is mundane: a VPS at Vultr or Hetzner runs from five to twenty euros a month, MetaTrader and Python are free, Dukascopy data is free. The barrier to entry is tens of euros monthly, not thousands. The bottleneck is time and statistical thinking, not money. A practical companion on running an EA on a VPS lives in the platforms and tools section on ForexMechanics.
What to do tomorrow
- Open a journal and for one week write down every entry you take as an unambiguous rule of the form "if X and Y, then open Z" — banishing words like "usually", "tends to", or "I feel that". If by the end of the week you cannot rewrite any decision as such a rule, you do not yet have a strategy to automate, only a collection of reactions.
- Download the free MetaTrader 5 from your broker, open a demo account, and configure three alerts in TradingView or the native MT5 alert system for the simplest version of your rule — observe for two weeks whether the alerts fire at the same moments you would have chosen manually.
- In week three register on mql5.com, open the MetaEditor bundled with MT5, and write the simplest possible Expert Advisor — an EMA 21 and SMA 55 crossover with a 1.5 ATR trailing stop — leaning on the MQL5 Reference documentation; the target is a first working EA in forty to eighty hours of effort, not a profitable one.
- After two months install Python 3.11 or newer, add pandas, NumPy and backtrader with pip install, work through the Backtrader Quickstart Guide, and re-implement the MQL5 EA as a backtrader strategy. Compare backtest outcomes on the same data — discrepancies above a few percent mean a hidden assumption is buried somewhere.
- Only in month five or six should you deploy the EA on a demo MetaTrader account hosted on a VPS at Vultr or Hetzner. Give it three months. If the demo performance lines up with the walk-forward backtest, only then consider a live account with capital whose loss would not move your monthly budget — five hundred to two thousand euros in the first iteration, no more.
Sources & bibliography
-
MetaQuotes MetaTrader 5 — Automated Trading · oficjalny opis automatycznego handlu w MetaTraderze, ścieżek pozyskania robota i miejsca strategy testera w warsztacie www.metatrader5.com ↗
-
MetaQuotes MQL5 Reference — programming language for algorithmic trading · dokumentacja referencyjna języka MQL5 i pięciu typów aplikacji (EA, indykatory, skrypty, serwisy, biblioteki) www.mql5.com ↗
-
Backtrader Backtrader Quickstart Guide · podręcznik startowy frameworka backtrader w Pythonie — strategie, indykatory, optymalizacja parametrów www.backtrader.com ↗
-
BIS BIS Quarterly Review, December 2019 — FX trading rises to $6.6 trillion per day · omówienie elektronicznej egzekucji i roli niebankowych principal trading firms w obrocie walutowym — kontekst dla retail algo www.bis.org ↗
Frequently asked
What retail algorithmic trading actually is — and what it is not?
Retail algorithmic trading means delegating the execution layer to the computer: the trader defines a rule as an unambiguous condition ("if the 21-period moving average crosses the 55-period average upward and the ATR of the last twenty bars is rising, open a long position sized at 1 percent of capital with a trailing stop of 1.5 ATR"), and the software recognises that condition and fires the order without hesitation, without checking Telegram, and without flinching from the latest losing trade. What an algorithm decidedly is not is a magical passive-income engine across three dimensions at once. It does not create an edge that did not exist — if the trader loses by hand, the bot loses faster and at lower cost. It does not protect against a regime change — if the history it was built on was trending and the market is now ranging, the equity curve melts just as efficiently as for a discretionary trader. And it does not fix logical flaws in the strategy itself — it merely encodes them more consistently.
What does the realistic ladder from clicking by hand to running a bot look like?
The first rung is platform alerts in TradingView or MT5 that fire a sound or email when the entry condition is met. The trader still clicks the order, but is forced to translate the strategy into unambiguous rules. The second rung is a simple Expert Advisor in MQL5 for MetaTrader, typically a moving-average crossover or a breakout from consolidation with a trailing stop; we cover this in our piece on MQL5 expert advisor basics. The third rung is a Python backtester with pandas, NumPy and backtrader that computes equity curves and risk metrics in a fraction of a second — explored in the article on Forex backtesting in Python. The fourth and optional rung is a direct broker connection through REST or FIX with Interactive Brokers or OANDA, leaving MetaTrader behind. The choice between MQL5 and Python is unpacked in trading bot — MQL5 versus Python. A realistic timeline runs from twelve to twenty-four months of evenings, not a weekend course on Udemy.
What skills do I actually need — and how does that differ from the "learn to code and get rich" myth?
Three things matter, in this order. First, statistical thinking: understanding the difference between win rate, profit factor and expectancy, and knowing why a fifty-trade equity curve proves nothing. Second, patience for the validation cycle: idea, coding, backtest, walk-forward, three to six months on demo, and only then a small amount of real capital. That cycle stretches over months and most traders drop out after two or three iterations. Third, programming basics: variables, loops, functions, control structures and some grasp of what a pandas DataFrame does. You do not need to be a software engineer — being able to read someone else's EA code and change a parameter without breaking the rest is enough. The "learn Python and get rich" myth skips the hardest and least photogenic part: owning a market edge worth automating. Without one, the code is just a faster way to burn through the deposit.
Why do most retail algo projects fail — and is there a precondition that improves the odds?
Algo projects do not fail because of coding bugs, even if there are plenty at the start. They fail because there is no edge to automate. The trader learns Python, writes a backtester, fits parameters to the last five years of data and gets an equity curve more beautiful than anything possible in real life — the classic curve fit. They go live, lose money, conclude they need "a better strategy" and repeat the loop. The precondition that dramatically improves the odds is the existence of an edge before the first line of code is written — a rule simple enough that in discretionary trading or in pure arithmetic on historical data it delivers a positive expectancy across multiple market regimes, not just the most recent one. How to isolate and validate such an edge is unpacked in the article on trading edge discovery. The second thing that separates lasting projects from one-off attempts is the willingness to accept an answer that says "your strategy has no edge, go back to the drawing board" — most traders prefer to over-optimise the parameters rather than hear it. An algorithm will not soften that message; it will only repeat it more quickly.