TAG

algorithmic-trading

  • November 8, 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 7, 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 4, 2025

What Is MetaEditor

Overview MetaEditor is the dedicated development environment for creating programs in MQL5, the programming language of MetaTrader 5. It is tightly integrated with the trading terminal and provides everything you need to write, compile, and debug trading algorithms. Each MQL5 program—whether a Script, Expert Advisor, Indicator, or Service—is first written as a source file with the extension .mq5 or .mqh, and then compiled into an executable .ex5 file that MetaTrader can run. Unlike a plain text editor, MetaEditor automatically highlights syntax, suggests function names, and helps you find errors during compilation. It is the starting point for any kind of automated system development in MetaTrader 5. What You Will Be Able to Do Code Example Execution Steps Key Point MetaEditor is more than a code editor—it is a full IDE (Integrated Development Environment) for MQL5. It helps you manage projects, compile efficiently, and debug issues before running programs in MetaTrader 5. Becoming familiar with its structure and workflow is the first practical step toward writing reliable trading algorithms. Next Section → Next: Your First Script

  • November 4, 2025

Getting Started with MQL5

Overview MetaTrader 5 is a comprehensive trading platform that allows traders to analyze markets, run indicators, and automate strategies. To make automation possible, MetaTrader includes its own programming language — MQL5 (MetaQuotes Language 5). It is a C-like language designed specifically for trading automation, allowing you to build scripts, indicators, and expert advisors (EAs) that execute trades automatically. MQL5 improves upon its predecessor, MQL4, by introducing object-oriented programming and faster execution, making it a robust choice for modern algorithmic trading. What You Will Be Able to Do Code Example Execution Steps Key Point MQL5 programs are executed within the MetaTrader 5 terminal environment. Each program type serves a distinct purpose — Scripts for one-time actions, Indicators for data visualization, Expert Advisors for automated trading, and Services for background tasks. Together, they form a flexible ecosystem that allows traders to automate nearly every aspect of their strategy. Next Section → Next: What Is MetaEditor