MACD Sample is a classic expert advisor for MetaTrader 4 that serves as an excellent educational example for learning to program and understand strategies with the MACD indicator. It combines crosses of several MACD indicators with moving averages to decide the trade direction and uses a dynamic stop loss to protect positions.
How it works
The robot analyzes the MACD crosses together with two moving averages to open buys or sells. It applies a trailing stop that follows price and contributes to a high percentage of winning trades. It was originally calibrated for GBPUSD on the 4 hour timeframe.
Configurable parameters
- Take Profit: profit target per trade, about 30 pips by default.
- Trailing Stop Loss: dynamic stop that follows price, about 60 pips by default.
- Optional fixed Stop Loss and a reference lot size.
Important note
This robot is shared for educational and study purposes. Long term backtests show negative results, so trading it live without modifications is not recommended. It is ideal for learning the MACD logic and practicing optimization in the Strategy Tester.
File contents: .mq4 source code ready to compile in MetaEditor. Use it on a DEMO account only.
View the original robot documentation on EarnForex (Apache-2.0 license)
