top of page

MACD Crossover on Nasdaq

Updated: Feb 1

A Classic MACD Crossover Strategy for Nasdaq 100


The Idea

This is a classic MACD crossover strategy with a tiny twist. The entry signal comes when the two lines cross (and the histogram crosses over 0), and the exit signal is given when the histogram has been climbing upwards for three days in a row. To ensure the market has a decent overall momentum we avoid trades if MACD is at its 20-period highest.


MACD crossovers can be powerful in trading because they pinpoint clear shifts in momentum, letting traders capture bullish moves and exit quickly if signals weaken.


Why is MACD Crossover so popular?

  • Clear Visual & Numeric Triggers:

    The MACD histogram, zero line, and signal line all create easy-to-spot crossover events.

  • Momentum Confirmation:

    Traders don’t just guess a reversal, they wait for momentum to turn positive (or negative) before taking a trade.

  • Versatility:

    MACD Crossovers can be applied to many markets (stocks, indices, forex, etc.) and across various timeframes.


A concept of an entry and exit signal

Setup for Backtest

Market: US Tech 100 (Nasdaq 100)

Contract: 1 € per point

Broker: IG

Testing environment: ProRealtime 12

Timeframe: Daily

Time zone: CET

No fees and commissions are included.

Result

Total gain: 5 165.3 €

Average gain: 19.6€

Total trades: 264

Winners: 175

Losers: 86

Breakeven:

Max drawdown: 593.7 €

Risk/reward ratio: 1.4

Total time in the market: 6.7 %

Average time in the market: 2 days, 6 hours

CAGR (10 000 € in starting capital): 2.71 %


Backtest Results

Entry Conditions

  1. MACD crosses over 0.

  2. MACD is less than its highest 20-period value.


Exit Conditions

  1. MACD is up three days in a row.


Code

ProRealTime

//-------------------------------------------------------------------------

// Concept: MACD cross

// Market: US Tech 100 / Nasdaq

// Direction: Long only

// Timeframe: Daily

// Timezone: CET

// Versions: v.1 | By: Algomatictrading.com | 2024-05-01 | OOS since: 2022-05-01

//-------------------------------------------------------------------------

defparam preloadbars = 500

defparam cumulateorders = false


// POSITION MANAGEMENT

//-------------------------------------------------------------------------

once positionsize = 1


// INDICATORS

//-------------------------------------------------------------------------

m = macd[12,26,9]


// TRADING CONDITIONS

//-------------------------------------------------------------------------

// Long - Enter

// ------------------

cl = m crosses over 0

cl = cl and m < highest[20](m)


// Long - Exit

// ------------------

clx = summation[3](m>m[1])=3


// TRADING ACTION

//-------------------------------------------------------------------------

// Enter

// ------------------

if cl then

buy positionsize contract at market

set stop %loss 5

endif


// Exit

// ------------------

if longonmarket and clx then

sell at market

endif


FAQ

Q: Am I free to use this strategy however I want?

A: Sure! But we're happy if you refer to our website and keep the creator's name in the code.


Q: I'm using another platform, can you write the code in another language?

A: No, sorry. We might add code in more languages later to the website, but until then, we recommend you try ChatGPT or something similar to help you rewrite it.


Q: Why does my backtest look different when I run the code?

A: The strategy might give different backtest results for several reasons, like added spread or fees, the wrong time-zone settings, or that you're using another type of contract.


Q: Will I make money if I run this strategy live?

A: We don't know. We're not financial advisors, we're just traders sharing our ideas.

bottom of page