The MACDLine function in ProBuilder language is used to calculate the Moving Average Convergence Divergence (MACD) line, which is a trend-following momentum indicator. The MACD line itself is the difference between two exponential moving averages (EMAs) of the price, typically over short and long periods. This function is crucial for identifying potential changes in market momentum and direction.
MACDLine[S,L,Si](price)
Where:
i1 = MACD[12,26,9](close)
i2 = MACDLine[12,26,9](close)
if(i1 < i2 AND i1[1] > i2[1]) THEN
bullishSignal = 1
bearishSignal = 0
ELSIF (i1 > i2 AND i1[1] < i2[1]) THEN
bullishSignal = 0
bearishSignal = -1
ELSE
bullishSignal = 0
bearishSignal = 0
ENDIF
RETURN bullishSignal, bearishSignal
This example demonstrates how to use the MACDLine function to generate trading signals. The code compares the MACD line (i2) with the MACD histogram (i1) to detect bullish and bearish crossovers. A bullish signal is set when the MACD line crosses above the histogram, and a bearish signal is set when it crosses below.