Our partnerSkilling
  • Spreads from 0.1 pips
  • 1,000+ instruments
  • Free demo account

65% of retail investor accounts lose money when trading CFDs with this provider.

Open account
Course 8 of 8 · Advanced

Algorithmic Trading for MetaTrader and cTrader

Learn to build your own trading robot. From idea and precise rules to finished code in MQL5, MQL4 and C# – with risk management, backtesting, optimisation without overfitting and the road to a demo account.

  • 6 modules
  • 19 lessons
  • 39 min reading
  • 16 quiz questions
  • Free
Start the course 0 of 19 completed

What you will learn

  • Turning a trading idea into precise rules
  • Basic programming for traders
  • A complete robot in MQL5, MQL4 and cTrader (C#)
  • Position size, trailing stop and filters in code
  • Backtesting, optimisation and overfitting
  • From demo account to real money – safely

Module 1What is algorithmic trading?Quiz: 3 questions

What a trading robot is, what it can and cannot do, the three platforms – and how to turn an idea into rules a computer understands.

  1. 1.1What is algorithmic trading?Algorithmic trading means letting a computer trade by fixed rules. Learn what a trading robot can do, what it cannot do, and the most common myths.2 min
  2. 1.2MetaTrader 4, MetaTrader 5 and cTraderThe three most used platforms for algorithmic trading among private traders – and what separates the languages MQL4, MQL5 and C#.2 min
  3. 1.3From idea to precise rulesA computer does not understand “buy when it looks good”. Learn to turn a trading idea into rules so precise that they can be programmed.2 min

Module 2Programming for tradersQuiz: 2 questions

What you need to know about programming to read and write a robot – explained without prior knowledge.

  1. 2.1Basics: variables, conditions and functionsThe four building blocks of all programming – variables, types, conditions and functions – explained with examples from a trading robot.2 min
  2. 2.2How a robot is builtAll robots have the same basic structure: one function when they start, one on every price change and one when they stop. Learn the events in MetaTrader and cTrader.2 min
  3. 2.3How to read indicators in codeHow to get values from moving averages, the RSI and other indicators in MQL4, MQL5 and cTrader – and why you use candles 1 and 2.2 min

Module 3Build your first robotQuiz: 2 questions

Step by step: a complete moving average crossover robot – first in MQL5, then in MQL4 and cTrader.

  1. 3.1Your first robot, part 1: settings and indicatorsWe build a complete robot in MQL5. Part 1: setup, input parameters and the indicators – with an explanation of every line.2 min
  2. 3.2Your first robot, part 2: signal and orderPart 2: We read the signal, count positions, send the order with stop loss and take profit – and have a complete robot in MQL5.2 min
  3. 3.3The same robot in MQL4How to write the MA crossover robot for MetaTrader 4 – and the most important differences between MQL4 and MQL5.2 min
  4. 3.4The same robot in cTraderHow to write the MA crossover robot as a cBot in C# for cTrader – and how to build and start it in the Algo app.2 min

Module 4Risk management in codeQuiz: 3 questions

Make the robot safe: position size based on risk, trailing stop, filters and error handling.

  1. 4.1Position size based on riskHow the robot calculates the position size so that every trade risks a fixed percentage of the account – in MQL5, MQL4 and cTrader.2 min
  2. 4.2Trailing stop, break-even and ATRHow to program a trailing stop and break-even, and how the ATR makes the stop loss and take profit fit the volatility.2 min
  3. 4.3Filters and error handlingHow to add time, trend and spread filters, check whether orders succeed, and use the log to find out what the robot is doing.2 min

Module 5Test the robot properlyQuiz: 4 questions

Backtesting, optimisation without overfitting, a VPS, and the road from demo to real money.

  1. 5.1Backtesting in the strategy testerHow to test the robot on historical data in MetaTrader and cTrader – which settings to choose, and which figures to look at.2 min
  2. 5.2Optimisation and overfittingWhy a perfect backtest is often a warning sign, what overfitting is, and how walk-forward and out-of-sample testing protect you.2 min
  3. 5.3VPS: let the robot run around the clockWhat a VPS is, why a trading robot needs one, which options you have in MetaTrader and cTrader – and what to look for.3 min
  4. 5.4From demo to real moneyHow to take the robot from backtest to demo account and on to a small real account – with follow-up and a plan for when to stop.2 min

Module 6Build your own robotQuiz: 2 questions

Use the algo builder as a starting point, extend the code yourself, and go through the whole process from idea to finished robot.

  1. 6.1Use the algo builder as a starting pointHow to use our algo builder to create a complete robot, and how the code it produces connects to what you have learned in the course.2 min
  2. 6.2Project: build your own robotThe final project: extend a robot with a new filter, test it properly and make a plan for demo – with a solution and checklist.2 min

BookshelfThe books behind the course

This course builds on these classics. If you want to go deeper, they are the best places to start.

  • Quantitative TradingErnest P. Chan (2008, 2nd ed. 2021)An easy-to-read introduction to algorithmic trading for individuals – with the most common backtesting mistakes.
  • Algorithmic TradingErnest P. Chan (2013)Concrete strategies such as mean reversion and momentum, and how to test them.
  • Building Winning Algorithmic Trading SystemsKevin J. Davey (2014)A step-by-step process from idea to live – with incubation, Monte Carlo and walk-forward.
  • The Evaluation and Optimization of Trading StrategiesRobert Pardo (2008)The standard work on optimisation and walk-forward analysis.
  • Expert Advisor Programming for MetaTrader 5Andrew R. Young (2013)A practical introduction to MQL5 for traders without a programming background.
  • Advances in Financial Machine LearningMarcos López de Prado (2018)For advanced readers: why most backtests are overfitted, and how to avoid it.