Return the value of the MACD histogram value over S,L and Si periods of price selected.
Syntax:
1 |
MACD[S,L,Si](price) |
Calculation:
The first value of the MACD is obtained by substracting the y days exponential moving average from the x days exponential moving average
The second value of the MACD is obtained by calculating a z days exponential moving average of the first one.
x, y and z are the MACD parameters, typically equal respectively to 12, 26 and 9.
The MACD histogram is obtained by substracting the second value from the first one.
Interpretation:
MACD is an excellent trend indicator, and partly minimises the delays obtained with the usage of simple moving averages.
There are 2 basic ways to use MACD:
Crossing:
A buy opportunily appears when MACD crosses upwards its signal line.
A sell signal may ne triggered when MACD crosses downwards its signals line.
The divergences between the MACD histogram an the price quote identify major reversal points and give strong buy/sell signals.
A bullish divergence occurs when stock prices make new lows
A bearish divergence occurs when the stock prices makes new highs while the MACD histogram fails to make new highs
The bullish and bearish divergences are more significant when the MACD is in an overbought or oversold level.
The opportunities appearing in longer time horizons (weekly,monthly..) generate larger price movements.
Example:
1 2 3 4 5 6 7 8 9 10 11 |
i1 = MACD[12,26,9](close) FOR i = 20 DOWNTO 0 DO IF(close[i]<close[i+1] AND i1>i1[1]) THEN result = 100 ELSE result = 0 ENDIF NEXT RETURN result |