MACD Sample Expert Advisor

MACD Sample Expert Advisor
Download ALL MT5 experts (1593)
YouTube Video Thumbnail



Similar MetaTrader Tools

MACD Sample Expert Advisor

Info

The MACD Sample Expert Advisor is a Expert Advisor for MetaTrader 5 that the macd sample ea is included in the standard pack of the client terminal and is an example of an ea that trades using the macd indicator. The file of the MACD Sample.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use MACD Sample Expert Advisor

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

The MACD Sample EA is included in the standard pack of the client terminal and is an example of an EA that trades using the MACD indicator.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: trade pad sample: building a trade symbols table - another powerful expert for MetaTrader 5 traders.

The MACD Sample EA is included in the standard pack of the client terminal and is an example of an EA that trades using the MACD indicator.

Also recommended: trade signals based on crossover of main and signal lines of macd indicator - similar expert with strong performance on MetaTrader 5.


The file of the MACD Sample.mq5 expert advisor is located in terminal_data_folder\mql5\experts\examples\macd. This expert advisor is an example of an object-oriented approach in EA development.

Let's consider the structure of the expert advisor and how it works.

- EA properties
- Include files
- Inputs
- Global variables
- Event handling functions
- The CSampleExpert class

The CSampleExpert class contains declaration of variables and functions. For a more convenient work with variables, all class member variables contain the prefix "m_" (member), which indicates that a variable is a class member.

The CSampleExpert class has five methods: constructor, destructor, init, deinit, and processing. The class member variables declared with the protected access modifier will be available only inside the CSampleExpert class methods (and child classes).

The init method of the CSampleExpert class initializes class member variables and verifies the input parameters. The initcheckparameters method checks the correctness of the EA input parameters. The initindicators method creates the MACD and EMA indicators.

The longclosed, shortclosed, longmodified, shortmodified, longopened, and shortopened methods return true if conditions for closing, modifying, or opening a position are met.

The processing method is the main method of the expert advisor. It is called in the OnTick event handler, and the time interval between successive calls of this method is monitored.

The best values of the parameters can be found using the Strategy Tester of the MetaTrader 5 terminal.

The MACD Sample expert advisor, included in the standard delivery pack of the terminal, is an example of an object-oriented approach in EA development.

You may also like: EXP_RMACD Expert Advisor - excellent alternative for expert users on MetaTrader 5.

Source Code

#property copyright "robotfx"
#property link "https://robotfx.org"
#property version     "5.20"
#property description "this code is educational. feel free to use, modify and upgrade as you wish. visit robotfx.org for professional trading tools"
#property description "this code is educational. feel free to use, modify and upgrade as you wish. visit robotfx.org for professional trading tools"
#property description "this code is educational. feel free to use, modify and upgrade as you wish. visit robotfx.org for professional trading tools"
#property description "this code is educational. feel free to use, modify and upgrade as you wish. visit robotfx.org for professional trading tools"
#include <trade\trade.mqh>
#include <trade\symbolinfo.mqh>
#include <trade\positioninfo.mqh>

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.