Most tools ask you to choose the periods. This one chooses them itself. The optimize macd settings indicator walks a grid of fast, slow and signal combinations, scores each against six hundred bars of history, and then plots whichever set came out on top.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Separate window |
| Plots | 6: MACD (best), Signal, ZeroLine, BUY, SELL, BiasMarker |
| Alerts | popup, push notification, email, sound |
| Inputs | 15 |
What the Optimize Macd Settings Indicator draws on the chart
Six plots below the price chart.
`MACD (best)` fills dodger blue columns.
`Signal` runs orange at width 2.
`ZeroLine` runs silver across the middle.
A lime `BUY` and a red `SELL` mark the crossings.
`BiasMarker` runs gold where the main line leads.
- MACD (best): histogram, dodger blue, width 2
- Signal: line, orange, width 2
- ZeroLine: line, silver
- BUY: arrow, lime, width 2, arrow code 233
- SELL: arrow, red, width 2, arrow code 234
- BiasMarker: line, gold

How the Optimize Macd Settings Indicator calculates its values
The grid
Six inputs bound it. `FastMin` `8` to `FastMax` `16`, `SlowMin` `21` to `SlowMax` `30`, and the signal range, all walked in `SweepStep` `2` increments.
Scoring each set
`SweepWindow` `600` bars decide it. The code builds every combination over that history, scores each one, and plots whichever scored highest.
The separation filter
`SignalMinExpand` `0.00003` of price sets a floor. Where the two lines barely part, no mark prints, which strips out the weakest crossings.
How to read the signals
The plotted periods come from the sweep, not from you.
They can change as the window rolls forward.
A wider grid costs more time on every rebuild.
The gold marker shows where the main line leads.
The separation floor scales with price.
Six hundred bars is the whole basis of the choice.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
`EnableAlerts` opens the group and arrives on with three of its members: `EnablePopup`, `EnablePushNotify` for the mobile terminal and `EnableSound`, which plays whatever `SoundFile` names. Only `EnableEmail` waits, and crossings report once a bar.
Every Optimize Macd Settings Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
SweepWindow |
bars used to score each config. Bars each combination is scored on, `600`. | 600 |
FastMin |
Lowest quick period tried, `8`. | 8 |
FastMax |
Highest quick period, `16`. | 16 |
SlowMin |
Lowest slow period, `21`. | 21 |
SlowMax |
Highest slow period, `30`. | 30 |
SignalMin |
Lowest signal period, `7`. | 7 |
SignalMax |
Highest signal period, `11`. | 11 |
SweepStep |
step between candidate periods. Gap between candidates, `2`. | 2 |
SignalMinExpand |
min |MACD-Signal| relative to price. Least separation, as a share of price, `0.00003`. | 0.00003 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
Top control over the marks, `true`. | on |
EnablePopup |
(see inputs panel) | on |
EnablePushNotify |
(see inputs panel) | on |
EnableEmail |
(see inputs panel) | off |
EnableSound |
(see inputs panel) | on |
SoundFile |
(see inputs panel) | alert.wav |

Settings that fit your chart
Six hundred bars is what the choice rests on, so pick a chart where that is a meaningful stretch. EURUSD H1 is the reference chart. That covers about a month there. On M5 it is two days. On H4 it reaches back four months.
When the Optimize Macd Settings Indicator fails
Periods chosen on past bars need not suit the next ones.
A rolling window means the chosen set can change under you.
Scoring a grid on every rebuild costs real time.
Six hundred bars is a small sample to pick from.
Copy the compiled Optimize Macd Settings Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Download the Optimize Macd Settings Indicator for MT4 and MT5
The zip holds the compiled Optimize Macd Settings Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
How does SweepWindow 600 pick the winning set?
The code builds each combination in the grid across those six hundred bars and scores it. Whichever scores highest becomes the set you see plotted, and everything afterwards uses that one choice.
Can the SweepWindow choice change mid-session?
Yes, and that is the main caution. The window rolls forward with new bars, so a different combination can win and the plotted line shifts, which a fixed-period MACD never does.
What does SignalMinExpand 0.00003 filter?
Crossings where the two lines barely separate. The floor takes a fraction of price rather than a fixed value, so it scales across symbols and removes the crossings that happen while both lines run together.
Does SweepStep 2 miss good combinations?
It can. Stepping by two halves the candidate count and therefore the calculation, at the cost of skipping every odd-numbered period. Setting it to one searches more thoroughly and runs noticeably slower.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Optimize Macd Settings Indicator as one input. Always backtest before trading live.
Category: this is part of our Oscillators collection. Browse more Oscillators for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- For background on this concept, see Allais paradox on Wikipedia.
- For broader market context, see Overbought at Investopedia.
