On this page
Back to tutorials

Build a MACD + RSI Confluence EA for MT5 — No Code

Combine MACD crossover with RSI trend filter in Strategy Builder — parameters, AND logic on Step 3, export MQL5, compile, and backtest.

📖 16 min read

📝 3,200 words

🏷️ MQL5 & Expert Advisors

Share this article:

Want to build a no-code strategy right now?

Create your free account in seconds and start building immediately.


Build a MACD + RSI Confluence EA for MT5 — No Code

Quick Answer: MACD + RSI Confluence EA Without Code

Quick answer: Open AlfaTactix Strategy BuilderStep 3 — SignalsBuy tab on H1 → add MACD (12/26/9 defaults) with condition Crossover: Target Signal Line, Direction Above → add RSI(14) with condition Compare: Operator >, Value 50 → combine both with AND → mirror on Sell (MACD cross Below signal AND RSI < 50) → optional Step 4 session filter → Step 5 stop loss / lot size → Save → export MQL5 from Code Generator → compile once in MetaEditor → backtest on H1 EURUSD with Every tick in the Strategy Tester.

Disclosure: This tutorial uses AlfaTactix Strategy Builder. For platform overview see Build EA Without Coding. For single-indicator EAs see RSI Overbought/Oversold EA and Moving Average Crossover EA.

Related guides: MACD indicator deep dive · RSI indicator deep dive · EA Risk Management · Backtest in Strategy Tester


What Is MACD + RSI Confluence?

A MACD + RSI confluence Expert Advisor waits for two momentum signals to agree before opening a trade. Instead of acting on MACD alone (which whipsaws in ranges) or RSI alone (which lags in trends), confluence combines:

LegIndicatorTypical rule
Momentum shiftMACDMACD line crosses above (buy) or below (sell) the signal line
Trend filterRSIRSI > 50 for longs, RSI < 50 for shorts

The EA runs in MetaTrader 5 on every tick or bar via OnTick(). You define both legs visually in Strategy Builder — no iMACD or iRSI code required.

Why traders search for this: MACD + RSI is one of the most common indicator pairs in forex education. Most tutorials show hand-written MQL5. This guide documents the same logic in Strategy Builder with every parameter and condition field the product exposes.

Confluence vs single indicator:

ApproachProsCons
MACD onlyCatches momentum shifts earlyMany false crosses in sideways markets
RSI 30/70 onlyClear mean-reversion zonesWeak in strong trends (RSI stays overbought)
MACD + RSI 50 confluenceFilters weak MACD crosses; aligns with trend biasFewer trades; both must agree

For pure RSI extreme entries (30/70), see RSI Overbought/Oversold EA — No Code. For trend-following without oscillators, see Moving Average Crossover EA.


Classic Settings for Confluence EAs

SettingStarter valueNotes
MACD12 / 26 / 9, EMA, CloseIndustry default; matches most chart presets
RSILength 14, Close, OB 70 / OS 30Use 50 as confluence threshold, not 30/70
TimeframeH1 (forex majors)M15 = more signals; H4 = cleaner trends
SymbolEURUSD, GBPUSDLiquid pairs; tight spread helps
LogicAND between MACD cross and RSI filterOR would fire on either alone — too loose

Works best: Trending or transitioning markets where MACD crosses coincide with RSI above/below the midline.

Struggles in: Choppy ranges — MACD crosses repeatedly while RSI oscillates around 50. Mitigate with Step 4 session/spread filters, RSI Cross 50 instead of Compare, or Step 5 stop loss.

Academy references: MACD indicator guide · RSI indicator guide


MACD and RSI Parameters in Strategy Builder

When you add indicators on Step 3 — Signals, the Parameters panel shows these fields (from product UI).

MACD parameters

ParameterTypeRange / optionsDefaultWhat it does
Fast LengthNumber1 – 10012Fast EMA period for MACD line
Slow LengthNumber1 – 10026Slow EMA period — must be > Fast Length
Signal LengthNumber1 – 1009EMA period for the signal line
SourceSelectClose, Open, High, LowClosePrice series for calculation
SmoothingSelectEMA, SMA, WMAEMAMA type (EMA is standard for MACD)

Validation: If Fast Length ≥ Slow Length, the builder shows an error — set Slow 26 and Fast 12 for the classic preset.

RSI parameters

ParameterTypeRange / optionsDefaultWhat it does
LengthNumber2 – 10014Lookback for RSI calculation
SourceSelectClose, Open, High, LowClosePrice series
SmoothingSelectNone, SMA, EMA, WMA, SMMA, VWMANoneOptional extra smoothing
Smoothing LengthNumber1 – 10014Active when Smoothing ≠ None
OverboughtNumber50 – 10070Upper zone (used in OB/OS conditions)
OversoldNumber0 – 5030Lower zone
OffsetNumber-50 – 500Bar shift (leave 0 for confluence EAs)

Tip for confluence: Leave Overbought/Oversold at 70/30 defaults even when your entry uses 50 — those levels still apply if you add Overbought/Oversold Cross conditions later.


Condition Types for MACD and RSI

Open an indicator on Step 3 → Add condition. Below is every condition type relevant to a MACD + RSI confluence EA.

MACD conditions

1. Compare

Compare the MACD line to a numeric value (typically the zero line).

FieldOptions / range
Operator>, <, >=, <=, ==, !=
ValueNumber (default 0 = zero line; typical range -0.001 to 0.001 on forex)

Use case: “Only buy when MACD line > 0” as an extra AND filter alongside the signal cross.


2. Crossover (core confluence leg)

Detect when MACD crosses a target.

FieldOptions
TargetSignal Line · Zero Line · Histogram
DirectionAbove (bullish) · Below (bearish)

Confluence recipe — Buy: Target Signal Line, Direction Above.
Sell: Target Signal Line, Direction Below.

Alternative: Target Zero Line for stronger trend confirmation (fewer signals).


3. Divergence

Price vs MACD disagreement — reversal hint.

FieldRange / options
Divergence TypeBullish Divergence · Bearish Divergence
Lookback Period5 – 50 bars (default 20)

Use case: Advanced entries — e.g. buy on Bullish Divergence AND MACD cross above signal. Not required for the starter confluence EA.


4. Histogram

Filter on MACD histogram state or direction.

FieldOptions
Histogram TypePositive · Negative · Increasing · Decreasing
ThresholdNumber (default 0 = zero line)

Use case: Add Histogram → Positive AND to the buy rule so momentum is already expanding when MACD crosses.


RSI conditions (confluence essentials)

For the full list of RSI condition types (Divergence, Failure Swing, Breakout, Pattern, Slope), see RSI Overbought/Oversold EA — No Code. For confluence, you mainly need Compare and Cross.

1. Compare (simple trend filter)

FieldOptions
Operator>, <, >=, <=, ==, !=
ValueNumber

Confluence recipe — Buy: Operator >, Value 50.
Sell: Operator <, Value 50.

Fires whenever RSI satisfies the inequality on the signal bar — easy to backtest.


2. Cross (timing-aligned filter)

Detect when RSI crosses a level.

FieldOptions
TargetRSI · Overbought · Oversold · 50
DirectionUp · Down
ValueNumber (used with some targets)

Confluence alternative — Buy: Target 50, Direction Up (RSI crosses above midline).
Sell: Target 50, Direction Down.

Fewer entries than Compare — often aligns better with the MACD cross bar.


Logical combinations on Step 3

Combine MACD and RSI with AND, OR, NOT, parentheses, and groups — same as Build EA Without Coding.

Starter expression:

(MACD Crossover Above Signal) AND (RSI Compare > 50)

Tighter expression:

(MACD Crossover Above Signal) AND (RSI Cross 50 Up) AND (MACD Histogram Positive)


Build the Confluence EA Step by Step

Workflow: six steps in Strategy Builder demo. We detail what matters for MACD + RSI confluence on H1.

Step 1 — Strategy information

  • Name: e.g. MACD RSI Confluence H1 EURUSD
  • Description: optional

Step 2 — Timeframes

  • Enable one trading timeframe, e.g. H1 (matches tab tf0 on Step 3).
  • Optional: add a higher timeframe for trend filter — see Advanced MTF Filters.

Step 3 — Signals (core)

Buy tab (H1)

  1. Open tab Buy → select timeframe H1.
  2. Add indicatorMACD (Momentum group).
  3. Parameters: Fast 12, Slow 26, Signal 9, Source Close, Smoothing EMA.
  4. Add conditionCrossover.
    • Target: Signal Line
    • Direction: Above
  5. Add indicatorRSI.
  6. Parameters: Length 14, Source Close, Overbought 70, Oversold 30, Offset 0.
  7. Add conditionCompare.
    • Operator: >
    • Value: 50
  8. Select both conditions → combine with AND.

Alternative RSI leg: Replace step 7 with Cross → Target 50, Direction Up.

Sell tab (H1)

  1. Open tab SellH1.
  2. Add MACDCrossover → Target Signal Line, Direction Below.
  3. Add RSICompare → Operator <, Value 50 (or Cross Target 50, Direction Down).
  4. Combine with AND.

Step 4 — Filters (optional)

Examples: market session (London/NY overlap), spread cap, ATR volatility filter. Reduces MACD whipsaw when RSI hovers near 50. Full reference: Advanced EA MTF & Filters.

Step 5 — Risk management

Minimum for a testable EA:

SettingSuggestion
Lot / risk %0.01 lot demo or 1% risk
Stop LossFixed pips or ATR-based
Take ProfitOptional; some traders exit on opposite MACD cross
One trade at a timeAvoid overlapping positions on same symbol

Full reference: EA Risk Management.

Step 6 — Preview and Save

Review Buy/Sell rules in the preview panel → Save strategy to your account.


Export, Compile, and Backtest

  1. Open Code Generator → select your saved strategy → MQL5 → download .mq5.
  2. Copy to MQL5/Experts, compile (F7) in MetaEditor.
  3. Strategy Tester: Every tick based on real ticks, realistic spread, 6–12 months on H1 EURUSD.
  4. Compare Compare vs Cross for the RSI leg — note trade count and profit factor.
  5. Forward test on Demo before live. Read Strategy Tester vs Live.

If OrderSend fails with 10016, see Invalid Stops.


Improvements: Filters and Risk

ProblemBuilder lever
Too many tradesSwitch RSI CompareCross 50; add MACD Histogram Positive AND
MACD whipsaw in rangeStep 4 session filter; Step 5 stop loss; avoid M5/M15 until tuned
RSI stuck near 50Require MACD Compare > 0 AND cross above signal
Strong trends, late entriesAccept fewer trades or drop RSI filter in trends (test carefully)
Over-tradingStep 5 max trades; one position per symbol

Related single-indicator EAs for comparison:

EA typeGuide
RSI extremes (30/70)RSI Overbought/Oversold EA
MA trend followingMoving Average Crossover EA

Next Steps

Try it: Strategy Builder demo — build the MACD signal cross + RSI 50 confluence EA in one session, export from Code Generator, and backtest.

References: MQL5 iMACD, MQL5 iRSI, MetaTrader 5 Strategy Tester.

Build your no-code trading strategy now — free

Create your account and start building a complete no-code strategy right now. Add indicators, filters, and risk rules, then export MQL5 in minutes.

Frequently Asked Questions

Yes. In AlfaTactix Strategy Builder, add MACD and RSI on Step 3 (Signals), combine a MACD Crossover (above signal line) with RSI > 50 for buy using AND, mirror for sell, set stop loss on Step 5, save, then export MQL5 from Code Generator. Compile once in MetaEditor and backtest in the Strategy Tester.

Confluence means two independent indicators agree before you enter. A classic rule: buy when MACD line crosses above the signal line (bullish momentum shift) and RSI is above 50 (buyers in control). Sell when MACD crosses below signal and RSI < 50. This filters many false MACD crosses in weak trends. Learn each indicator in the MACD Academy guide and RSI Academy guide.

Standard starters: MACD 12 / 26 / 9 (fast / slow / signal) with EMA smoothing on Close, plus RSI(14) with overbought 70 and oversold 30. For confluence EAs, RSI 50 acts as a trend filter — not the 30/70 extremes used in mean-reversion systems like the RSI Overbought/Oversold EA. Test on H1 EURUSD first.

Compare (RSI > 50) fires whenever RSI is above 50 on the signal bar — simpler, more entries. Cross (Target 50, Direction Up) fires only when RSI crosses above 50 — fewer, cleaner entries aligned with the MACD cross timing. Both work; start with Compare for backtests, switch to Cross if you get too many signals. Full RSI condition reference: RSI Overbought/Oversold EA guide.

You export .mq5 from Code Generator and compile once (F7) in MetaEditor. You do not write MACD/RSI logic by hand — see Production-Ready MQL5 Without MetaEditor and Build EA Without Coding.

Add Step 4 session or spread filters (Advanced MTF Filters), require RSI Cross 50 Up instead of Compare, use MACD Histogram Positive as a third AND condition, or add a higher-timeframe trend filter. Always set Stop Loss on Step 5 per EA Risk Management and forward-test on Demo before live.

Build your no-code strategy now — free

Create Free Account