MQL5 Articles Index

  • November 24, 2025

Summary and Next Steps

Overview By this point in the MQL5 Learning Roadmap, you have walked through the entire basic workflow of algorithmic trading in MetaTrader 5. You started with simple scripts, learned how to use Print() and logs for debugging, explored indicators and their values, created basic Expert Advisors, and ran them in the Strategy Tester with configurable parameters. This section summarizes what you have learned and suggests clear next steps for deepening your skills and building real trading systems. What You Will Be Able to Do Code Example The following simplified example shows how many concepts from earlier sections come together in one Expert Advisor. It uses input parameters, reads indicator values, and writes messages to the log inside OnTick(). Execution Steps Key Point All the topics you studied—scripts, indicators, Expert Advisors, OnTick(), parameters, and logs—are building blocks of one continuous workflow. By combining them, you can design, test, and refine complete automated trading strategies in MQL5. Next Section → Next: About the Printed BookIn the next section, you will learn how the printed book complements this roadmap and where to go next for more detailed examples and advanced topics.

  • November 24, 2025

Reading the Log

Overview When you develop programs in MQL5, the log is your primary source of truth about what is actually happening inside the terminal. MetaTrader 5 records messages from your Expert Advisors, indicators, and scripts, along with system events and errors. These messages are shown in different tabs such as Experts, Journal, and, when testing, the Strategy Tester output. Learning how to read these logs will dramatically improve your ability to debug and refine your trading algorithms. What You Will Be Able to Do Code Example Execution Steps Key Point Effective debugging in MQL5 starts with the log. By combining meaningful Print() messages with careful reading of the Experts and Journal tabs, you can understand the exact sequence of events, detect errors early, and verify that your trading logic behaves as expected. Next Section → Next: Summary and Next Steps

  • November 24, 2025

Working with Parameters

Overview Input parameters in MQL5 let you configure a program without editing its source code. By declaring variables with the input keyword, you expose them in the EA/Script settings dialog and in the Strategy Tester, making your logic flexible, testable, and ready for optimization. What You Will Be Able to Do Code Example Execution Steps Key Point Use input for user-facing, configurable settings; use normal variables for internal state. Typed inputs (including enums) make your EA safer and easier to test, and they integrate seamlessly with the Strategy Tester for optimization. Next Section → Next: Reading the Log

  • November 24, 2025

Running in the Strategy Tester

Overview The Strategy Tester in MetaTrader 5 lets you run your Expert Advisors (EAs) on historical data to verify logic, performance, and risk—without using real money. You can backtest on different symbols and timeframes, review reports and logs, and even optimize input parameters to search for better settings. Mastering the tester is a crucial step before any live deployment. What You Will Be Able to Do Code Example This minimal EA uses an input parameter (fast MA period) so you can adjust it in the tester and later optimize it. Execution Steps Key Point Backtesting validates logic and reveals performance characteristics before risking capital. Use inputs to make scenarios reproducible and optimization-ready, and always confirm findings on out-of-sample data to avoid overfitting. Next Section → Next: Working with Parameters

  • November 24, 2025

Before Using OrderSend

Overview Before you call OrderSend() in MQL5, you must prepare a valid trade request and verify the trading environment. This includes checking terminal permissions, symbol settings, volume constraints, filling mode, and prices. Use OrderCheck() to validate a request and review the broker’s response before sending a live order. What You Will Be Able to Do Code Example Execution Steps Key Point Validate first, trade second. Always normalize volume, confirm symbol settings, pick a supported filling mode, and run OrderCheck(). Proper pre-trade checks prevent most rejections and improve EA reliability. Next Section → Next: Running in the Strategy Tester

  • November 24, 2025

The OnTick Function

Overview In an Expert Advisor, the OnTick() function is executed automatically every time a new market tick arrives — meaning each time the Bid or Ask price changes. This makes it the central “loop” of your EA, where decisions are evaluated and orders are executed. Every trading algorithm in MQL5 depends on how efficiently OnTick() processes incoming data. What You Will Be Able to Do Code Example Execution Steps Key Point OnTick() is event-driven — it runs automatically for each market update. It’s the heart of every Expert Advisor, where signals, calculations, and trade executions are performed. Keep OnTick() efficient and lightweight to ensure your EA runs smoothly, even on fast-moving markets. Next Section → Next: Before Using OrderSend

  • November 24, 2025

What Is an Expert Advisor

Overview An Expert Advisor (EA) in MQL5 is an automated trading system that runs inside MetaTrader 5. It monitors the market, makes trading decisions, and can execute orders automatically based on your strategy. Unlike scripts, which run once and stop, an EA operates continuously — it reacts to every market tick or event. EAs are written in the same MQL5 language used for indicators and scripts, but they rely on special event-handling functions to process data and react to market updates. What You Will Be Able to Do Code Example Execution Steps Key Point An Expert Advisor is event-driven: OnInit() runs once at startup, OnTick() executes on every market update, and OnDeinit() runs when the EA is removed. This structure makes it ideal for continuous strategy execution, order management, and monitoring. Next Section → Next: The OnTick Function

  • November 24, 2025

Reading Indicator Values

Overview In MQL5, indicator outputs are stored in buffers. You access these buffers programmatically using a handle (e.g., from iMA(), iRSI()) and the CopyBuffer() function. This lets your scripts and Expert Advisors consume analytical data directly for decisions. What You Will Be Able to Do Code Example Execution Steps Key Point Indicator outputs live in buffers. Create a handle, call CopyBuffer() for the desired buffer index and bar range, then release the handle with IndicatorRelease(). Use ArraySetAsSeries(true) when you want buf[0] to represent the most recent bar. Next Section → Next: What Is an Expert Advisor

  • November 24, 2025

What Are Indicators

Overview In MQL5, an indicator analyzes market data and visualizes results on a chart or subwindow. Unlike Scripts and Expert Advisors, indicators do not send orders; they compute values and draw them as lines, histograms, or arrows so you can interpret trends and signals. You can use built-in indicators (e.g., Moving Average, RSI) or create custom ones with MQL5. What You Will Be Able to Do Code Example Execution Steps Key Point Indicators compute and draw values; they do not trade. They are often used as inputs to Expert Advisors or for visual decision support on charts. Next Section → Next: Reading Indicator Values  

  • November 24, 2025

Getting the Symbol Name

Overview Many MQL5 programs need to know which instrument they are running on. The built-in Symbol() function returns the current chart’s symbol as a string, allowing you to print it for diagnostics or use it to request prices, trade, or load indicator data. What You Will Be Able to Do Code Example Execution Steps Key Point Symbol() is context-sensitive: it returns the symbol of the chart where the program runs. When an EA must handle multiple instruments, pass symbol names explicitly instead of relying on the current chart context. Next Section → Next: What Are Indicators