Bullish MACD Crossover

The purpose of this indicator is to detect the crossover of the MACD oscillator lines. A bullish crossover happens when the MACD line crosses up through the signal line.

Open the Indicator Builder from the menu.

Card image cap

Bullish MACD crossover

  1. Add a MACD operator in the top row.
  2. Click the MACD row, then click the plus symbol in the toolbar to add a new row above
  3. Set the new row to a Step function
  4. From the first selector in the MACD row, select Difference
  5. Add a new top row again, and set it to Dirac Delta
  6. Add another row and set that to Threshold
  7. Add a final row and set it to Buy


We use the Difference output from the MACD and pass that into a step function. The MACD difference line is the MACD line minus the signal line. When the Difference line crosses from minus to plus that is the same as the MACD line crossing up through the signal line.

The step function simply shows where the Difference line is above zero. As we’re only interested in the step itself, we can use a Dirac Delta which will create a positive or negative value at the step edges and will be zero everywhere else. The image below shows the output of Dirac Delta on the step function.

Card image cap

Output of Dirac Delta on step function

As we only want to detect bullish crossovers, we use the Threshold function to remove negative values from the Dirac Delta. This now gives us just the places where the MACD line is crossing up through the signal line.

Card image cap

Bullish MACD crossover

To detect the bearish crossovers, where the MACD line moves down through the signal, we would just need to have added a Negate operator above the delta function.

Lastly, the Buy will create a buy signal whenever it’s input is true. This completes the logic. Now we can test the indicator on different symbols and timeframes. The chart above shows the bullish crossovers on Amazon stock (Weekly chart). As we can see, buying at the crossovers was successful 73% of the time, over this range, and delivered an average profit of 24.7%

Use this Indicator

Risk Disclosure: Information given on this website is for general purposes only and should not be construed as investment advice. Certain instruments shown here are complex and may come with a high risk of losing money rapidly due to leverage. You should consider whether you understand how these instruments work and whether you can afford to take the high risk of losing your money. Market data displayed is indicative and is not a solicitation to buy or sell.