Algorithmic trading โ algotrading โ is simply the practice of automating a trading idea into a computer program that executes without manual intervention. The strategy logic, entry rules, exit conditions, and position sizing are all defined in code. When the conditions are met, the system acts.
The concept is not new. The principles behind it, however, are frequently misunderstood by those just starting out.
What Is a Trading Platform?
A trading platform is software that connects you to financial markets, allowing you to place orders for instruments including currencies, stocks, bonds, commodities, and futures. MetaTrader 4 is the most widely used platform for retail algotrading โ it is programmable via its native MQL4 language, supports automated strategies through Expert Advisors, and provides an integrated Strategy Tester for backtesting.
Automation does not change the fundamental challenge of trading. It automates your idea. If the idea is flawed, automation makes it fail faster and more efficiently.
The 7 Golden Rules
1. Start With a Trading Idea
Algotrading begins with a trading hypothesis โ a set of rules you would follow manually if you were watching the screen. What conditions signal an entry? What defines an exit? What stops the trade?
An algorithm is not a magic system that discovers edges on its own (see rule 2). It is the mechanical implementation of a human idea, stripped of discretion and emotion.
Before writing any code, you must be able to express your strategy in precise, unambiguous rules. If you cannot state your entry condition in plain language, you cannot code it.
2. Keep It Simple
Complex strategies with many conditions and parameters are harder to validate, harder to debug, and more susceptible to over-fitting. A strategy with three conditions is easier to understand than one with fifteen โ and usually more robust.
Every parameter you add to a system is another degree of freedom that can be curve-fitted to historical data. The simpler your model, the more confident you can be that its historical performance reflects a genuine edge rather than optimised noise.
3. Define Entry and Exit Rules Precisely
Vague rules produce vague code that behaves unexpectedly. Every condition must be exact:
- Not "buy when RSI is low" โ but "buy when RSI(14) crosses above 30 on the close of the current H1 bar"
- Not "exit when the trade looks bad" โ but "exit when price closes below the 20 EMA on the entry timeframe"
Precision also makes backtesting meaningful. Ambiguous rules lead to different interpretations between your backtest and your live EA, producing results that cannot be compared.
4. Prioritise Money Management
The risk management layer of your strategy is as important as the signal layer โ arguably more so.
Define before you code:
- Maximum risk per trade (typically 1โ2% of account equity)
- Stop loss logic โ fixed pip value, ATR-based, or structure-based
- Position sizing formula relative to the stop distance
- Maximum simultaneous open trades
A strategy with a modest win rate but disciplined risk management can be highly profitable. A strategy with a high win rate but poor risk management can still blow an account.
5. Do Not Chase Perfection
There is no perfect trading strategy. Every system has losing streaks. Every system fails in some market conditions.
The goal is not to find a system that wins every trade โ it is to find a system with a statistically significant edge over a large sample of trades and the robustness to maintain that edge across varied market conditions.
Waiting for the "perfect" system is a form of procrastination. Build a working system, test it rigorously, and deploy it. Improve iteratively from live results.
6. Backtest Before You Trade
Running your Expert Advisor over historical data prices is not optional โ it is the minimum standard for responsible deployment.
Backtesting answers:
- Does this strategy have a historical edge at all?
- What is the worst drawdown I should expect?
- How does performance change across different instruments and timeframes?
An EA deployed on a live account without backtesting is a hypothesis being tested with real money. The Strategy Tester exists precisely to avoid this.
7. Validate Out-of-Sample
Backtesting on data used to build the strategy produces optimistic results. The strategy has, in effect, seen the test in advance.
Out-of-sample validation โ testing the strategy on data it was never optimised against โ is the real measure of robustness. If performance holds up on unseen data, the edge is more likely to persist in live trading.
Walk-forward analysis formalises this process and should be a standard step before any live deployment.
Algorithmic trading levels the emotional playing field. Your code will never deviate from the rules because it is scared, tired, or overconfident. But the rules themselves must be sound. These seven principles are what make the difference between a system worth automating and one that should never have been written.