TAG

expert-advisor

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