MACD Master [SimpleAlgo]

📊 INTRODUCING MACD MASTER
The MACD is on more charts than almost any other indicator, and it is still drawn the way it was drawn decades ago: two thin lines and a row of bars in a box under the chart. It tells you whether momentum is with the buyers or the sellers and whether it is growing or shrinking. It leaves the practical questions open. Which of its crosses are worth marking? Where does this candle have to close for the next one? How long until it crosses if price goes nowhere?
MACD Master is the standard MACD turned into a toolkit that answers those. The crosses that turn the MACD back from a stretched level are marked on the chart as Overbought and Oversold. A dashed line and a tag show the exact close at which the next cross would happen, before it happens. Divergences are found and drawn on both the chart and the pane. A clock in the pane shows how many candles the cross is away if price stands still. The candles take the histogram's four colours, and a panel puts all of it into words.

🖼️ The look
Momentum is drawn in four colours. Bright up colour means the MACD is above its signal line and the gap is growing. Dim up colour means it is above and the gap is shrinking. Bright down colour means it is below and the gap is growing. Dim down colour means it is below and the gap is shrinking. The histogram columns and the candles use the same four, so the price chart and the pane always say the same thing. The MACD line takes one of two colours, one for each side of its signal line, and the space between the line and zero glows in that colour, strongest at the line and clear at zero. A solid dot on the line is a signal. A hollow ring is any other cross.
On the price chart the script draws the candle colours, the signal labels, the divergence lines, one dashed line with its tag, and the panel in a corner. When the same signal comes again before the opposite one, it is marked with a dot instead of the word, so a run reads as one label followed by dots.
💡 What's different
⚙️ HOW IT WORKS
🧮 1. The MACD
The calculation is the standard one and we have not changed it. The MACD line is an EMA of the close over the fast length minus an EMA of the close over the slow length. The signal line is an EMA of the MACD line. The histogram is the gap between the two:
Pine Script®
With the default lengths of 12, 26 and 9, these are the same three values as TradingView's built-in MACD.
🚦 2. The four states
The histogram is above zero or below it, and it is either further from zero than it was on the last candle or closer. That gives four states, numbered 0 to 3: up and building, up and fading, down and building, down and fading:
Pine Script®
The state colours the histogram column and the candle above it. The panel also says how many candles in a row the current state has lasted.
🎯 3. The cross price
An EMA is a blend. Its new value is a fixed share of the newest close plus the rest of its own last value, and that share is 2 divided by the length plus 1. So the next value of both EMAs, and with them the next MACD value, is known for any close the next candle might have. The signal line is an EMA of the MACD, so it is known too. Work it through and the histogram of the next candle is zero exactly when the new MACD value equals the signal line as it stands now. Solving that for the close gives one price:
Pine Script®
A close above it leaves the MACD above its signal line. A close below it leaves it below. We checked it against what the MACD then did on 473,672 real candles across 32 charts, and it was on the right side every time.
While a candle is forming, the price that decides it is the one solved from the last closed candle. It does not move during the candle. When the candle closes, a new price is solved for the next one:
Pine Script®
Most of the time price is on the safe side of it and the tag reads "close below" or "close above" that price. About one candle in twenty, price is already on the far side. Then the MACD is going to cross unless price comes back, and the tag says "unless above" or "unless below". Hover over the tag for the full sentence.
🟢 4. Signals
A cross is the candle on which the histogram changes sign, and it counts once that candle has closed:
Pine Script®
The grey band in the pane is a set distance on each side of the zero line, half an ATR by default, with the ATR measured over the slow length:
Pine Script®
A signal is a cross that turns the MACD back toward zero from outside that band. A cross up counts when the signal line was below the band on the candle before. A cross down counts when it was above it:
Pine Script®
The up signal is labelled Oversold and the down signal Overbought, because that is where they happen: the MACD has been stretched away from zero and has just turned. On the charts we tested, RSI had usually dropped to a low reading during the move before an up signal, and risen to a high one before a down signal. The labels can say Buy and Sell instead, or be plain dots.
Because the rule looks at the candle before the cross, the script knows in advance whether the next cross would be a signal. When it would, the tag and the panel read "Next signal". When it would not, they read "Next cross":
Pine Script®
In a trend the MACD stays on one side of zero, so the same signal tends to repeat. Only the first of a run is written out. The rest are dots:
Pine Script®
📒 5. The record
Every cross is followed for five candles. If the MACD crosses its signal line the other way inside those five, the cross was undone:
Pine Script®
If it is still on the same side after five, the cross held:
Pine Script®
Signals and every other cross are counted apart, and the panel shows both shares once the chart has at least 20 of each. The record says how long a signal lasted. It does not say whether price followed it.

📐 6. Divergences
Divergences are measured wave to wave. Every stretch the MACD spends under its signal line is one wave, with one lowest MACD value and one lowest low. The script keeps both as the wave goes:
Pine Script®
The cross up ends the wave. If price went lower than in the wave before it and the MACD did not, that is a bullish divergence:
Pine Script®
The mirror rule, on the waves above the signal line, finds a bearish divergence when price goes higher and the MACD does not. Each one is drawn as two lines on the candle that ends the wave, low to low on the chart and trough to trough in the pane. Nothing depends on pivots that need candles on both sides, so a divergence is never drawn late and never redrawn.
⏱️ 7. The clock
The cross price says how far the cross is in price. The clock says how far it is in time. Both EMAs are carried forward one candle at a time as if every coming candle closed at the latest price, and the signal line with them, until the histogram changes side:
Pine Script®
The two lines are drawn dotted to the right of the last candle, to the point where they meet, with the number of candles written there. It is exact for the case it describes. Price will not stand still, so read it as "this cross is close even if nothing happens" or "this cross needs a real move". The clock looks 20 candles ahead and says so when there is no cross inside them.
🪟 8. The panel
Hover over the Next signal, If price stays here and Signals rows for a reminder of what they show.
🧪 WHAT WE TESTED, AND WHAT WE FOUND
We ran the script's rules over more than 36,000 MACD crosses on 32 charts: index futures, forex, gold, oil, Bitcoin and stocks, from 5 minute to daily. For each cross we looked at which way price went next, and at how long the cross itself lasted.

So read the labels for what they are. Overbought and Oversold say that momentum was stretched and has turned, and that the turn is likely to hold for a while. They do not say that price will reverse.
🎨 Repainting
Values for closed candles never change. Signals, dots, rings and divergence lines appear only once the candle that crossed has closed, and are never moved or removed. The cross price shown during a forming candle is solved from the last closed candle, so it stays where it is until that candle closes. The MACD, the histogram, the candle colour and the clock of the forming candle move with price, as they do in any MACD, and are final at the close. Nothing is requested from another symbol or timeframe, so nothing looks ahead.
🧩 WHY IT IS ORIGINAL
The MACD itself is the classic and is left untouched. What we built around it is our own work:
📘 HOW TO USE IT
🌱 If you're new
The MACD measures momentum: how fast price has been moving lately compared with a little longer ago. Above zero, recent prices are higher than the longer average. Below zero, they are lower. When the MACD line crosses its signal line, momentum has changed direction. That is all a cross means. This script shows you where those crosses are, which ones tend to last, and where the next one would be.
🔧 SETTINGS
🔔 ALERTS
Signals and divergences fire on the close of the candle. "Price reached the next cross price" fires during the candle, as an early warning that a close beyond that level would cross the MACD.
📝 NOTES AND LIMITS
⚠️ DISCLAIMER
This script is a tool for reading momentum. It is not financial advice and it does not predict price. What we describe above comes from past data on the charts we tested and says nothing certain about any other chart or about the future. Trading involves risk, including the loss of your capital. Make your own decisions and manage your own risk.
The MACD is on more charts than almost any other indicator, and it is still drawn the way it was drawn decades ago: two thin lines and a row of bars in a box under the chart. It tells you whether momentum is with the buyers or the sellers and whether it is growing or shrinking. It leaves the practical questions open. Which of its crosses are worth marking? Where does this candle have to close for the next one? How long until it crosses if price goes nowhere?
MACD Master is the standard MACD turned into a toolkit that answers those. The crosses that turn the MACD back from a stretched level are marked on the chart as Overbought and Oversold. A dashed line and a tag show the exact close at which the next cross would happen, before it happens. Divergences are found and drawn on both the chart and the pane. A clock in the pane shows how many candles the cross is away if price stands still. The candles take the histogram's four colours, and a panel puts all of it into words.
🖼️ The look
Momentum is drawn in four colours. Bright up colour means the MACD is above its signal line and the gap is growing. Dim up colour means it is above and the gap is shrinking. Bright down colour means it is below and the gap is growing. Dim down colour means it is below and the gap is shrinking. The histogram columns and the candles use the same four, so the price chart and the pane always say the same thing. The MACD line takes one of two colours, one for each side of its signal line, and the space between the line and zero glows in that colour, strongest at the line and clear at zero. A solid dot on the line is a signal. A hollow ring is any other cross.
On the price chart the script draws the candle colours, the signal labels, the divergence lines, one dashed line with its tag, and the panel in a corner. When the same signal comes again before the opposite one, it is marked with a dot instead of the word, so a run reads as one label followed by dots.
💡 What's different
- It names the price of the next cross. The tag reads, for example, "Next signal: Oversold, close above 81,443.40". That number is solved from the MACD's own formula. It is not an estimate.
- It separates the crosses that last from the ones that don't. Only a cross that turns the MACD back toward zero from outside the grey band is a signal, and the panel shows on your own chart how the two kinds compare.
- It gives the cross a clock. Both lines are carried forward to where they would meet if price stood still.
- It says what it measured. We tested every part on 32 real charts, and the results, including the unflattering ones, are in this description.
⚙️ HOW IT WORKS
🧮 1. The MACD
The calculation is the standard one and we have not changed it. The MACD line is an EMA of the close over the fast length minus an EMA of the close over the slow length. The signal line is an EMA of the MACD line. The histogram is the gap between the two:
With the default lengths of 12, 26 and 9, these are the same three values as TradingView's built-in MACD.
🚦 2. The four states
The histogram is above zero or below it, and it is either further from zero than it was on the last candle or closer. That gives four states, numbered 0 to 3: up and building, up and fading, down and building, down and fading:
The state colours the histogram column and the candle above it. The panel also says how many candles in a row the current state has lasted.
🎯 3. The cross price
An EMA is a blend. Its new value is a fixed share of the newest close plus the rest of its own last value, and that share is 2 divided by the length plus 1. So the next value of both EMAs, and with them the next MACD value, is known for any close the next candle might have. The signal line is an EMA of the MACD, so it is known too. Work it through and the histogram of the next candle is zero exactly when the new MACD value equals the signal line as it stands now. Solving that for the close gives one price:
A close above it leaves the MACD above its signal line. A close below it leaves it below. We checked it against what the MACD then did on 473,672 real candles across 32 charts, and it was on the right side every time.
While a candle is forming, the price that decides it is the one solved from the last closed candle. It does not move during the candle. When the candle closes, a new price is solved for the next one:
Most of the time price is on the safe side of it and the tag reads "close below" or "close above" that price. About one candle in twenty, price is already on the far side. Then the MACD is going to cross unless price comes back, and the tag says "unless above" or "unless below". Hover over the tag for the full sentence.
🟢 4. Signals
A cross is the candle on which the histogram changes sign, and it counts once that candle has closed:
The grey band in the pane is a set distance on each side of the zero line, half an ATR by default, with the ATR measured over the slow length:
A signal is a cross that turns the MACD back toward zero from outside that band. A cross up counts when the signal line was below the band on the candle before. A cross down counts when it was above it:
The up signal is labelled Oversold and the down signal Overbought, because that is where they happen: the MACD has been stretched away from zero and has just turned. On the charts we tested, RSI had usually dropped to a low reading during the move before an up signal, and risen to a high one before a down signal. The labels can say Buy and Sell instead, or be plain dots.
Because the rule looks at the candle before the cross, the script knows in advance whether the next cross would be a signal. When it would, the tag and the panel read "Next signal". When it would not, they read "Next cross":
In a trend the MACD stays on one side of zero, so the same signal tends to repeat. Only the first of a run is written out. The rest are dots:
📒 5. The record
Every cross is followed for five candles. If the MACD crosses its signal line the other way inside those five, the cross was undone:
If it is still on the same side after five, the cross held:
Signals and every other cross are counted apart, and the panel shows both shares once the chart has at least 20 of each. The record says how long a signal lasted. It does not say whether price followed it.
📐 6. Divergences
Divergences are measured wave to wave. Every stretch the MACD spends under its signal line is one wave, with one lowest MACD value and one lowest low. The script keeps both as the wave goes:
The cross up ends the wave. If price went lower than in the wave before it and the MACD did not, that is a bullish divergence:
The mirror rule, on the waves above the signal line, finds a bearish divergence when price goes higher and the MACD does not. Each one is drawn as two lines on the candle that ends the wave, low to low on the chart and trough to trough in the pane. Nothing depends on pivots that need candles on both sides, so a divergence is never drawn late and never redrawn.
⏱️ 7. The clock
The cross price says how far the cross is in price. The clock says how far it is in time. Both EMAs are carried forward one candle at a time as if every coming candle closed at the latest price, and the signal line with them, until the histogram changes side:
The two lines are drawn dotted to the right of the last candle, to the point where they meet, with the number of candles written there. It is exact for the case it describes. Price will not stand still, so read it as "this cross is close even if nothing happens" or "this cross needs a real move". The clock looks 20 candles ahead and says so when there is no cross inside them.
🪟 8. The panel
- Momentum: the state and how long it has lasted. "Down, fading for 2 bars".
- Next signal or Next cross: what the next cross would be, the close it takes, and how far that is. "Oversold on a close above 81,443.40, 27.08% away".
- If price stays here: the clock in words. "Crosses up in 8 bars".
- Zero line: which side of zero the MACD line is on and for how long. "Below for 26 bars".
- Last signal: what it was and how long ago. "Overbought, 49 bars ago, with a divergence".
- Signals: the chart's own record. "21% undone within 5 bars, other crosses 32%".
Hover over the Next signal, If price stays here and Signals rows for a reminder of what they show.
🧪 WHAT WE TESTED, AND WHAT WE FOUND
We ran the script's rules over more than 36,000 MACD crosses on 32 charts: index futures, forex, gold, oil, Bitcoin and stocks, from 5 minute to daily. For each cross we looked at which way price went next, and at how long the cross itself lasted.
- A MACD cross does not predict direction. Price went with the cross about as often as it went against it. We tried 17 versions of the rule, including crosses that agree with a higher timeframe, crosses on the trend side of the 200 EMA and zero line crosses. None of them changed that.
- The signals are no exception. They are not a prediction either, and only taking them with the trend did not make them one.
- What the signals do is last. They were undone by the opposite cross within five candles about half as often as every other cross. That held on every chart that had enough crosses to count, and the Signals row shows the two numbers for your own chart.
- They repeat. Most signals are the same as the one before, because a trend keeps the MACD on one side of zero. Oversold can be followed by Oversold at a lower price, more than once.
- Divergence leaned slightly. The crosses that ended a divergence did a little better than the others. It is a small lean, the only one we found, and in a trend divergences fail in a row.
So read the labels for what they are. Overbought and Oversold say that momentum was stretched and has turned, and that the turn is likely to hold for a while. They do not say that price will reverse.
🎨 Repainting
Values for closed candles never change. Signals, dots, rings and divergence lines appear only once the candle that crossed has closed, and are never moved or removed. The cross price shown during a forming candle is solved from the last closed candle, so it stays where it is until that candle closes. The MACD, the histogram, the candle colour and the clock of the forming candle move with price, as they do in any MACD, and are final at the close. Nothing is requested from another symbol or timeframe, so nothing looks ahead.
🧩 WHY IT IS ORIGINAL
The MACD itself is the classic and is left untouched. What we built around it is our own work:
- The cross price: the next cross solved as an exact close, shown before the candle closes, and named a signal in advance when it would be one.
- The signal rule: a cross back toward zero from outside an ATR band, chosen because it is the kind of cross that measurably lasts, with a per chart record that proves or disproves it on the chart in front of you.
- Wave to wave divergence, confirmed on the cross that ends the wave, with no pivots and no redrawing.
- The clock: both lines projected forward under a stated assumption to the candle where they meet.
- Runs drawn as one word followed by dots.
📘 HOW TO USE IT
- Know the price before the candle closes. If you act on MACD crosses, the tag tells you where the cross is, so you can plan around it or set a price alert there.
- Tell a lasting cross from a passing one. A solid dot outside the band has held far more often than a ring inside it. The Signals row shows the two numbers for your chart.
- Use Overbought and Oversold as context. They mark stretched momentum that has turned. In a trend, expect dots: the same condition coming back.
- Watch divergences with the trend in mind. One divergence after a long move is worth noticing. A string of them in a strong trend is the trend, not a reversal.
- Read the candles. Dim candles mean the current push is losing strength, bright ones mean it is gaining.
🌱 If you're new
The MACD measures momentum: how fast price has been moving lately compared with a little longer ago. Above zero, recent prices are higher than the longer average. Below zero, they are lower. When the MACD line crosses its signal line, momentum has changed direction. That is all a cross means. This script shows you where those crosses are, which ones tend to last, and where the next one would be.
🔧 SETTINGS
- Fast length, Slow length, Signal length: the standard MACD inputs. 12, 26 and 9 by default.
- Signals on the chart: on or off, and what the labels say: Overbought and Oversold, Buy and Sell, or Dots.
- Band width: the grey band, in ATRs on each side of zero. 0.5 by default. Wider gives fewer signals, further from zero. 0 removes the band.
- Divergences: the divergence lines on the chart and in the pane.
- Next cross price: the dashed line and its tag.
- Cross clock: the dotted projection in the pane and its row in the panel.
- Colour the candles: the four state colours on the price chart.
- Glow under the MACD line: the fill between the line and zero.
- Colours: Mint and Pink, Ice, Neon, or your own two colours.
- Text size and Panel: sizes, and where the panel sits. Auto moves it out of the way of the latest candles.
🔔 ALERTS
- Signal up (Oversold, Buy)
- Signal down (Overbought, Sell)
- MACD crossed up (any cross)
- MACD crossed down (any cross)
- Bullish divergence
- Bearish divergence
- Price reached the next cross price
- MACD above zero
- MACD below zero
- Momentum started fading
Signals and divergences fire on the close of the candle. "Price reached the next cross price" fires during the candle, as an early warning that a close beyond that level would cross the MACD.
📝 NOTES AND LIMITS
- The cross price and the clock are exact for EMAs, which is what the MACD uses. They describe the MACD, not where price will go.
- On symbols with very little history the record shows "Not enough crosses on this chart yet" until there are 20 signals and 20 other crosses.
- When a run of signals started off screen you will see its dots without the word. Scroll back, or read the Last signal row.
- The chart keeps the most recent 500 labels and 500 lines. Older ones drop off on very long histories.
- The band is measured in ATRs so it means the same on every symbol and timeframe. If a chart gives you too many or too few signals, change the band width, not the MACD.
⚠️ DISCLAIMER
This script is a tool for reading momentum. It is not financial advice and it does not predict price. What we describe above comes from past data on the charts we tested and says nothing certain about any other chart or about the future. Trading involves risk, including the loss of your capital. Make your own decisions and manage your own risk.
Access our exclusive invite-only scripts: simplealgo.io
Join our discord: discord.gg/simplealgo
Join our discord: discord.gg/simplealgo
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
Access our exclusive invite-only scripts: simplealgo.io
Join our discord: discord.gg/simplealgo
Join our discord: discord.gg/simplealgo
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน