Register
Strategy guide

MACD Trend Following Strategy: Rules, Exits and Filters

A MACD trend following strategy buys when MACD shows momentum turning up and sells when it turns down, on the view that moves which have started tend to continue for a while. The usual signal is the MACD line crossing its signal line; the usual filter is the zero line, which shows whether the 12-period EMA is above or below the 26-period EMA. Trend following trades late on purpose. On the model series used in this guide, the signal-line rule went short 5 sessions after the high and long 8 sessions after the low; adding a zero-line filter made both entries later still and turned the short into a loss. This guide sets out complete rules for Nifty futures on daily candles, applies two versions of them to the same model Nifty series, and covers stops, sizing, option versions, costs, testing and the QuantPower setup.

QuantPower Research · Updated 12 Nov 2026 · 19 min read

The MACD trend following strategy at a glance

ItemSetting
InstrumentNifty futures, or options on the same signal
CandlesDaily for swing trades; 15-minute for intraday versions
IndicatorMACD (12, 26, 9)
Long entryMACD line crosses above the signal line
Short entryMACD line crosses below the signal line
FilterOptional: trade longs only above zero, shorts only below
ExitThe opposite cross, or a trailing stop
Initial stop1.5% from the entry on daily candles
Best marketLong, steady trends
Worst marketSideways ranges and sharp V-shaped turns

How MACD works, in brief

The MACD line is the 12-period EMA of the closes minus the 26-period EMA. The signal line is a 9-period EMA of the MACD line, and the histogram is the gap between the two. A cross of the signal line shows the gap between the averages changing direction; a cross of zero shows the averages themselves crossing. The calculation, each part and the settings are worked through step by step in the guide to the MACD indicator.

With standard settings MACD needs 34 closes before the signal line exists, and many more before its values stop depending on where the calculation began. Load at least a year of daily data before the first signal you use.

Why trend following can work, and when it fails

Trend following rests on one observation: prices sometimes move a long way in one direction, and a rule that holds through those moves can make more on them than it loses on many small false starts. The rule does not need to predict the turn. It needs to stay in the trade while the trend lasts and get out without a large loss when it does not.

That shapes the results of every trend rule:

  • Many small losses, a few large gains. Most signals in a range fail quickly. The few that catch a long move pay for them.
  • A low win rate is normal. Trend rules often win fewer than half their trades. The ratio of the average gain to the average loss matters more.
  • Long flat or losing stretches. In a sideways year the rule can lose for months. Testing has to include such years.
  • V-shaped turns hurt. When the market reverses sharply, the rule exits late and enters the new direction late, and can lose on both.

The rules

The plain version: signal-line crosses

  1. Long: buy one lot when the daily MACD line closes above its signal line.
  2. Short: sell one lot when it closes below the signal line.
  3. Reverse: each opposite cross closes the trade and opens one the other way.
  4. Initial stop: 1.5% from the entry price.
  5. Size: set from the rupee loss at the stop, not from the margin.

The filtered version: signal line and zero line

  1. Long: buy when the MACD line is above both its signal line and zero.
  2. Short: sell when the MACD line is below both its signal line and zero.
  3. Exit: close the trade on the opposite signal-line cross. Do not reverse until both conditions hold the other way.
  4. Initial stop and size: as above.

Why the filter matters

The filter keeps the strategy on the side of the slower trend. A bullish signal-line cross below zero is a fall slowing down; a bullish cross above zero is a rise resuming. In a range, where MACD hovers near zero and crosses its signal line often, the filter removes many of the false starts. The price is lateness: every entry has to wait for the averages themselves to cross.

The model Nifty series

The examples use a model series of 72 daily closes, a seeded random walk that is not market data. It rises to 25,500.00 on day 32, falls 5.26% to 24,158.55 on day 44 and recovers to 25,867.60 by day 72. The same series is used in the guides to MACD, RSI, moving averages and Bollinger Bands.

DayCloseMACD lineSignal lineEvent
3225,500.00203.05Not yet availablePrice high
3724,938.05141.09164.05MACD crosses below its signal line
4124,483.65−23.2882.59MACD crosses below zero
4424,158.55−136.66−7.24Price low
5224,799.05−108.00−130.70MACD crosses above its signal line
5624,933.902.50−69.03MACD crosses above zero
7225,867.60236.92171.87Last session

A worked trade on Nifty futures

The plain version, on one lot of Nifty futures of 65 units. The example treats the futures price as equal to the index and shows the mechanics, not a record of results.

One lot of Nifty futures, MACD signal-line rule (model closes)
  1. Day 37, closethe MACD line, 141.09, closes below its signal line, 164.05. Sell one lot at 24,938.05, five sessions and 561.95 points below the high. Stop 1.5% above, at 25,312.12, a risk of ₹24,315.
  2. Day 41, closeNifty at 24,483.65 and MACD below zero. The short is 454.40 points, or ₹29,536, in profit. The rule does nothing: there is no opposite cross.
  3. Day 44, closethe low, 24,158.55. The short is 779.50 points in profit, ₹50,668, but nothing in the rules marks this as the bottom.
  4. Day 52, closeMACD crosses back above its signal line. Buy two lots at 24,799.05: one to close the short for a gain of 139.00 points, ₹9,035, and one to open a long. New stop 1.5% below, at 24,427.06.
  5. Day 72, closeNifty at 25,867.60. The long is 1,068.55 points, or ₹69,456, in profit and still open, because MACD has not crossed down again.
  6. Costsabout ₹970 for the short's round trip and the same again when the long is closed.

Two things stand out. The short gave back most of its open profit: it was 779.50 points ahead at the low and closed 139.00 points ahead, because the exit waited for the cross. That is the cost of a rule that exits on confirmation rather than on a level. And the long caught most of the recovery because nothing in the rules ended it early. Trend following lives on trades like the long and has to survive trades like the short.

The same series with the zero-line filter

Plain versionFiltered version
Short entryDay 37 at 24,938.05Day 41 at 24,483.65
Short exitDay 52 at 24,799.05Day 52 at 24,799.05
Short result+139.00 points−315.40 points
Long entryDay 52 at 24,799.05Day 56 at 24,933.90
Long open at day 72+1,068.55 points+933.70 points

On this series the filter cost money at both turns: the short started after most of the fall and lost when the market rebounded, and the long started 134.85 points higher. The series has two sharp turns and no sideways stretch after day 25, which is the market where a filter helps least. In a long range, the same filter would have kept the strategy out of crosses that the plain version traded and lost on. One series cannot settle which version is better; a test over several years, including sideways ones, can.

Exits

The opposite cross is the simplest exit and the slowest. A trailing stop loss or a histogram rule keeps more of a move. The common choices compare like this:

ExitHow it worksOn the model short from day 37
Opposite signal-line crossClose when MACD crosses backDay 52 at 24,799.05, +139.00 points
Histogram turnClose when the histogram moves against the trade for two bars in a rowDay 46 at 24,319.60, +618.45 points
Trailing stop on closesClose when the price closes beyond the extreme close of the last 5 sessionsDay 49 at 24,332.45, +605.60 points

The histogram exit on the short fires when the histogram rises for two sessions in a row: it bottomed at −129.41 on day 44 and rose on days 45 and 46. The trailing exit fires when the close rises above the highest close of the previous five sessions. Both kept far more of the move than the cross did, and both would also close many good trend trades early in a steadier trend. Exits are where most of the testing effort belongs.

Giving back open profit

The worked short shows the hardest part of trend following to live with. At the low on day 44 the trade was 779.50 points ahead, ₹50,668 on one lot. It closed on day 52 at 139.00 points ahead, ₹9,035. It gave back 640.50 points, ₹41,633, while the rule waited for MACD to cross back. Nothing went wrong: the rule did exactly what it was built to do.

Traders who cannot accept that usually override the rule after a few such trades, and the overrides tend to come at the worst moments. Two honest alternatives exist. One is a faster exit, chosen in advance and tested, such as the histogram or trailing exits above. The other is to scale out of part of the position, which locks in some gain without giving up the trend.

Scaling out of a trend trade

A common plan closes half the position when the open gain equals the initial risk and lets the other half run on the original exit. On the model long from day 52, the initial risk was 371.99 points, so the first half would close on the first close at or above 25,171.04. That came on day 62, at 25,191.55, for a gain of 392.50 points on the half. The second half was still open on day 72, 1,068.55 points ahead.

Scaling out lowers the swing in the account and the gain on the best trades. Whether it improves a strategy depends on how often trades reach the first target and then reverse, which only a test on many trades shows. It also needs at least two lots, or two option spreads, to split.

Long-only and long-short versions

The rules above trade both sides. A long-only version buys on the bullish cross and goes flat on the bearish one. It avoids holding a short through a sharp rally and suits traders who prefer bought calls or call spreads to shorts. On the model series it would have been flat from day 37 to day 52 and long from day 52, missing the short's 139.00 points and taking the same long.

Index markets have tended to rise over long periods, so long-only trend rules on Nifty give up fewer good trades than long-only rules in a market with no long-term drift. Shorts still matter for hedging a portfolio and for options strategies built on bearish signals.

Filters that reduce false signals

  • The zero line. Longs above zero, shorts below.
  • A long moving average. Longs only above a rising 200-day average, shorts only below a falling one.
  • ADX. Trade crosses only when ADX is above 20 to 25, which marks a trending market.
  • The higher timeframe. Take 15-minute crosses only in the direction of the daily MACD.
  • Event days. Skip entries the day before the RBI policy, the Union Budget and similar events, when a gap can jump past the stop.

Each filter removes trades. Add one at a time and keep it only if it improves results across many years, not just the last one.

MACD settings compared

SettingSignal line fromCrosses on the model series
(12, 26, 9)Day 34Short day 37, long day 52
(8, 17, 9)Day 25Long day 26, short day 36, long day 50
(5, 35, 5)Day 39Long day 49
(19, 39, 9)Day 47Long day 54

Faster settings trade more and turn sooner; slower ones trade less and need more history. The standard (12, 26, 9) is a reasonable default. Changing it until past crosses line up with past turns is the most common way to overfit a MACD rule.

MACD on Bank Nifty and stocks

The rules carry over unchanged, but the numbers do not. MACD is measured in points, so its values on Bank Nifty, near 56,000, run about 2.2 times larger than on Nifty for the same percentage move; compare signals, not values. A 1.5% stop on Bank Nifty is about 840 points, ₹25,200 on one lot of 30, close to the rupee risk of a Nifty lot at the same percentage. Stocks gap on results and news, which can jump through a stop, and stock futures held to expiry settle by delivery of shares, so close or roll them before the expiry week. To compare momentum across stocks, use the percentage price oscillator rather than MACD itself.

A short history of MACD trend following

Trend-following rules on moving averages are older than MACD. Richard Donchian, who ran one of the first public commodity funds from 1949, traded futures on moving-average and channel rules, and by the 1970s systematic trend followers were managing money on the same ideas.5 Gerald Appel built MACD in the late 1970s as a trend and momentum tool: the difference between a fast and a slow exponential average, with a signal line to time the turns.1 Thomas Aspray added the histogram in 1986 to give earlier warning of crosses.2

MACD spread with charting software in the 1980s and 1990s, and it is now one of the indicators every Indian charting platform carries; Arth.live charts, inside QuantPower, include it with its standard settings. What has changed most is testing. A rule that once had to be checked by hand on charts can now be run over years of data with costs in minutes, which makes it easy to test, and just as easy to overfit. In India, the costs to include have also changed: STT on futures rose from 1 April 2026,3 and the NSE's F&O session now runs to 3:40 pm from 3 August 2026.4

Intraday MACD

On 15-minute candles the rules are the same, with three changes. The trade closes by 3:15 pm whatever the signal. Entries in the first 15 minutes after 9:15 am are skipped, because the opening gap moves both EMAs at once. And the daily MACD sets the direction: only buy 15-minute bullish crosses while the daily MACD is above its signal line. Intraday trades are smaller in points, so costs take a much larger share of each gain.

Trading the signal with options

A trend trade on Nifty futures makes or loses ₹65 a point on one lot. Options can carry the same signal with a known loss. Trend trades last weeks, so monthly expiries suit them better than weekly ones. Model values with Nifty at 25,000, 30 days to expiry and IV of 14%, per lot of 65:

  • Long call: buy the 25,000 call at ₹469.35, or ₹30,508. The most it can lose is the premium.
  • Bull call spread: buy the 25,000 call and sell the 25,500 call for a debit of ₹222.33, or ₹14,451. The maximum profit is ₹18,049 at or above 25,500.
Nifty after the signalFuturesLong callBull call spread
Up 400 points after 10 sessions+₹26,000+₹10,410+₹5,179
Flat after 10 sessions₹0−₹6,287−₹923
Down 300 points after 10 sessions−₹19,500−₹15,583−₹5,249
Up 800 points after 20 sessions+₹52,000+₹25,677+₹12,576

The long call pays for time while the trend develops; the spread loses far less when it does not, and gives up the upside beyond 25,500. For a strategy whose signals fail more often than they succeed, the smaller loss on failed signals often matters more than the capped gain on the good ones.

Position sizing

Size from the loss at the stop. A 1.5% stop on Nifty near 25,000 is about 373 points, ₹24,250 on one lot. With 1% of capital at risk per trade:

AccountRisk budget at 1%Futures lots at a 1.5% stop
₹10,00,000₹10,0000
₹25,00,000₹25,0001
₹50,00,000₹50,0002

A smaller account cannot hold one futures lot at this stop within 1%. The choices are a spread, whose maximum loss is known, a tighter stop, which will be hit more often, or a larger share of the account at risk. The bull call spread above risks ₹14,451 at most.

Costs, slippage and tax

  • Futures charges come to about ₹970 for a round trip in one Nifty lot, most of it the 0.05% STT on the sale.3 That is about 15 points a trade.
  • Option charges are far lower, about ₹200 for a two-leg spread's round trip, because STT is charged on the premium, not the contract value.
  • Slippage is worst on stops in fast markets. Allow a point or two per order on index futures.
  • Rollover. A trend trade held through the monthly expiry has to be rolled to the next contract, which costs a second round trip and the spread between the two contracts.
Charges calculator

Brokerage, STT, exchange charges, SEBI fee, stamp duty and GST for one round trip, by broker.

Profits from futures and options are generally taxed as non-speculative business income.

How to backtest a MACD strategy

  1. Use enough data. Several years of daily candles, including trending and sideways years.
  2. Act on closed candles. A cross that appears mid-session can vanish by the close.
  3. Include costs and slippage. Every trade, including rollovers.
  4. Test the exits separately. Keep the entry fixed and compare exits, then the other way round.
  5. Change one setting at a time. If results swing a lot between neighbouring settings, the rule is fragile.
  6. Keep data back. Design on one part of the history and judge on another.
  7. Read the trade list. Count the longest losing streak and the deepest drawdown; they decide whether the rule can be followed in practice.

Setting up the MACD strategy in QuantPower

RuleExample setting
InstrumentNifty futures, current month; close and re-enter in the next month before the expiry week
CandlesDaily
EntryMACD (12, 26, 9) line crosses above its signal line; optionally also above zero
ExitThe opposite cross, or a stop and target
Stop1.5% from the entry
Size1% of capital at risk between entry and stop
Account limitsSmart Exit, the daily loss limit and the kill switch, set before the first trade

Step 1. Test the rule on past candles

In QuantPower's rule backtest, choose Nifty futures and daily candles, write the entry as "MACD line crosses above signal line", set the stop at 1.5%, and add the opposite cross as the exit rule. The backtest reads up to 2,000 past candles from your connected broker, about eight years of daily candles, holds one position at a time, and deducts slippage and charges from every trade. Change one setting at a time and rerun; a rerun with only the slippage changed is free. See backtesting for how to read the result.

Step 2. Create the signals

In Algos → Signal algos, create a signal on Nifty futures with the condition "MACD line crosses above signal line", checked on closed daily candles. Add the zero-line filter as a second condition if you use it; a signal can combine up to 20 conditions in ALL and ANY groups. Create a second signal for the opposite cross, which closes the position.

Step 3. Choose one-touch or auto

In one-touch mode, the signal tells you when it fires and the order is ready; you place it with one touch. In auto mode, once armed, the signal places the order itself, with every risk check. Any change to the condition or the order disarms it. A signal that places its own order costs no tokens.

Step 4. Set the stop

Place the stop and target as a GTT order with two legs (OCO): the first to trigger cancels the other. A GTT can wait up to 365 days, so it covers a trend trade that lasts weeks. On the chart, the GTT's lines can be dragged to a new price, and the order sheet shows the old and new trigger before anything is sent.

Step 5. Forward test it

Point the signals at your Forward test account and let them trade on live prices with test money until they have taken several trades. See forward test for how Forward test fills orders. Compare the fills with the backtest.

Step 6. Set the account limits

Smart Exit sets a profit target, a stop-loss and a trailing step for the whole account, and on a hit it stops the algos and squares off. The daily loss limit refuses new orders once today's loss reaches it. The kill switch stops trading in a segment until that segment's next session. Set them before the first live trade.

Step 7. Monitor, roll and pause

Review the trades each week. Before the expiry week, close a trade that is still open and re-enter in the next month's contract, or let the signal take the next entry there. To stop all trading at once if the market does something the rules did not plan for, use the kill switch; to stop one signal, disarm or delete it.

When to stop trading the strategy

Decide in advance what would make you pause the strategy, while you can still judge it calmly. Common limits are a losing streak longer than the longest one in the backtest, a drawdown more than about one and a half times the backtest's worst, or a change in the market's behaviour, such as months of tight ranges. Pausing is not the same as abandoning: review the trades, compare them with the backtest's, and restart only if the differences are explained.

Common mistakes

  • Expecting MACD to catch tops and bottoms. It confirms turns after they happen.
  • Trading every cross in a range. Use a filter, and test whether it helps.
  • Exiting on the cross only. Test faster exits; the opposite cross can give back most of a move.
  • Sizing by margin. Size from the loss at the stop.
  • Forgetting rollover. A trend held through expiry costs a second round trip.
  • Tuning the settings to the last year. Keep the defaults unless several years of tests support a change.

Pre-trade checklist

  • The signal is on a closed daily candle.
  • The filter, if used, agrees with the trade.
  • No scheduled event falls before the next session.
  • The stop is set before entry, and the size follows from it.
  • The rollover date is known for a trade that may last past expiry.
  • The rules were backtested with costs and tested on unseen data.
  • The strategy has taken several trades in Forward test.

Where MACD trend following is going

MACD itself does not change; what changes is how it is used. Rule backtests on broker data and signal algos that act on closed candles make a MACD rule something a trader can test, run and review without watching every session. The retail algo framework in force since 1 April 2026 puts automated rules like these through brokers under exchange oversight.6 AI assistants can now write the conditions from a sentence, which makes it quicker to test ideas and easier to test too many. The discipline that matters is the old one: fixed rules, costs counted, and enough trades to judge them.

Start with 500 free tokens

Connect your broker, build a strategy and test it on paper before a single live order goes out.

Frequently asked questions

Which MACD settings do most traders use?

The standard 12, 26, 9 is the most widely used. Faster settings react sooner with more false signals; slower settings react later with fewer.

Is MACD a leading or lagging indicator?

Lagging. It is built from moving averages, so it confirms trends after they begin.

Can I use MACD for intraday trading?

Yes, on intraday candles such as 15-minute charts, ideally with a filter such as VWAP or the daily MACD, and with all trades closed before the end of the session.

What does a MACD crossover mean?

When the MACD line crosses above the signal line, short-term momentum is strengthening relative to its recent average. A cross below means it is weakening.

Should I trade MACD crosses below zero?

A bullish cross below zero marks a fall slowing down, which is the weaker kind of buy signal. Many trend rules skip it and wait for MACD to cross zero, accepting a later entry for fewer false starts.

Does a MACD strategy work on weekly charts?

The rules work on any timeframe. On weekly candles the standard settings cover about three and six months, so signals are rare, often only a few a year, and each trade lasts months. Positional traders often take the direction from the weekly MACD and the timing from the daily one.

How long does a MACD trend trade last?

On daily candles, from a few sessions for failed signals to several weeks or months for trades that catch a trend. The longest trades usually make most of the strategy's gains.

References

  1. Gerald Appel, *Technical Analysis: Power Tools for Active Investors* (FT Prentice Hall, 2005)
  2. Thomas Aspray, "Fine-tuning the MACD", *Technical Analysis of Stocks & Commodities* 4(4) (1986)
  3. Union Budget 2026-27: securities transaction tax on futures and options raised from 1 April 2026 (indiabudget.gov.in)
  4. NSE, circular on F&O trading hours to 3:40 pm from 3 August 2026, and Nifty futures contract specifications (nseindia.com)
  5. Michael W. Covel, *Trend Following* (FT Press, 2004), on Richard Donchian and early trend-following funds
  6. SEBI, circular on safer participation of retail investors in algorithmic trading, 4 February 2025, in force for every broker from 1 April 2026 (sebi.gov.in)
Figures on this page use a model Nifty series and model option prices, not market data, and the worked trades show the mechanics, not a record of results. Trading involves substantial risk, and this guide is not investment advice.