In this section, you will see how to create a custom stock chart—MACD—that is a momentum oscillator offering trend following and momentum. It fluctuates above and below the zero level.
Note
You can read more about this at http://en.wikipedia.org/wiki/MACD.
Let's derive the technical requirements for the MACD chart, which we will use as a foundation to implement our custom chart.
For the MACD chart, based on the stock data that contains open, high, low, and close values for different time instances, the following values need to be calculated:
Once the preceding values are calculated, the MACD-related values will be calculated for a record, by applying the following formulae:
MACD line = 12-day EMA - 26-day EMA
Signal line = 9-day EMA of MACD line
MACD histogram = MACD - Signal line
After the MACD line, signal line, and histogram values have been calculated, we need to draw a chart between...