MACD Crossover System

You are here:
< All Topics

One of the more popular trading systems because of its simplicity and effectivity, the MACD line and signal line can be used in the same way as we use the Stochastic indicator, meaning the crossover between the two lines provides buy or sell signals.

//Buy when MACD Line crossed up, otherwise sell

//set variables
set macd_line = MACD(13, 26, 9, EXPONENTIAL)
set macd_signal =  MACDSIGNAL(13, 26, 9, EXPONENTIAL)
set hist = macd_line – macd_signal

//Buy condition
Set Buy=  CROSSOVER(macd_line , macd_signal)

//Sell Condition
Set Sell = CROSSOVER(macd_signal, macd_line)

//Plot MACD
plot(macd_line, line, any, macd)
plot(macd_signal, line, any, macd)
plot(hist, bar, any, macd)

//Plot Buy and sell signals
Plot(Buy, Buy, Green, main)
Plot(Sell, Sell, Red, main)

Previous Trading Systems Introduction
Table of Contents