Gandalf Expert Advisor: Trend Smoothing Strategy

Gandalf Expert Advisor: Trend Smoothing Strategy
Download ALL MT5 experts (1731)
YouTube Video Thumbnail



Similar MetaTrader Tools

Gandalf Expert Advisor: Trend Smoothing Strategy

Info

The Gandalf Expert Advisor: Trend Smoothing Strategy is a Expert Advisor for MetaTrader 5 that the gandalf expert advisor is inspired by a forum discussion. Note: Optimization is required.

Usage

This tool is typically used for trend following strategies across multiple currency pairs.

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 Gandalf Expert Advisor: Trend Smoothing Strategy

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 Gandalf Expert Advisor is inspired by a forum discussion.

Typical Use Case

This Expert Advisor excels in trend following 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: VPS Toolkit: Secure Order Sending and Restart-Safe State for Expert Advisors - another powerful expert for MetaTrader 5 traders.

The Gandalf Expert Advisor is inspired by a forum discussion.

Also recommended: Automated Live Testing for Expert Advisors on Demo Accounts - similar expert with strong performance on MetaTrader 5.


Note: Optimization is required!

The EA manages one buy position and one sell position simultaneously. These are two independent trades that remain open until closed by a predefined Take Profit or Stop Loss.

The trading logic is based on a two-parameter exponential smoothing of a time series. The smoothing considers two main factors:
1. Price position (parameter S)
2. Trend slope (parameter T)

The calculations utilize recurrence formulas:
S[n] = w * Y[n] + (1 - w) * (S[n-1] + T[n-1])
T[n] = t * (S[n] - S[n-1]) + (1 - t) * T[n-1]

The predicted value is calculated as: Y[n+1] = S[n] + T[n]

Source values for the first and second parameters can be derived from linear regression formulas.


Expert Advisor Inputs

For Long Positions:
- in_buy: Boolean, allows or disallows long positions.
- count_buy: Integer, the number of history bars used for time series smoothing.
- w_price: Float, the price factor.
- w_trend: Float, the trend factor.
- sl_buy: Integer, the stop loss level in pips.
- risk_buy: Float, the risk level as a percentage of free margin.

For Short Positions: The parameters in_sell, count_sell, m_price, m_trend, sl_sell, and risk_sell function similarly to their long position counterparts.


Optimization Process

Optimization is conducted in two distinct steps, initially using a fixed lot size (when risk_buy=0 and risk_sell=0).

Step 1 (Long Positions):
- Set in_buy=true and in_sell=false.
- Optimize count_buy from 3 to 120 (step 1).
- Optimize w_price and w_trend from 0.05 to 0.6 (step 0.01).
- Optimize sl_buy from 30 to 100 (step 1).

Step 2 (Short Positions):
- Set in_buy=false and in_sell=true.
- Optimize the remaining parameters similarly to Step 1.

Performance Notes:
The Expert Advisor demonstrates effective trading during clear trend periods on H4 and D1 timeframes, particularly for EURUSD. It is recommended to incorporate an additional filter using an indicator on higher timeframes to refine market entry signals. This strategy was last updated in 2026.

You may also like: Programmatically Attach Expert Advisors with Custom Inputs to MetaTrader 5 Charts - excellent alternative for expert users on MetaTrader 5.

Source Code

/

.......

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.