MACD - Pine Script
MACD - Pine Script
// Getting inputs
sma_signal = input.string(title = "Signal Line MA Type", defval = "EMA", options = ["SMA", "EMA"],
display = display.data_window)
// Calculating
alertcondition(hist[1] >= 0 and hist < 0, title = 'Rising to falling', message = 'The MACD histogram
switched from a rising to falling state')
alertcondition(hist[1] <= 0 and hist > 0, title = 'Falling to rising', message = 'The MACD histogram
switched from a falling to rising state')
plot(hist, title = "Histogram", style = plot.style_columns, color = (hist >= 0 ? (hist[1] < hist ? #26A69A
: #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #FF5252)))