Skip to content
All library documents

Using MACD and Stochastic RSI in Trading Charts

Article FMZ forum · Author: 发明者量化-小小梦

Summary

This tutorial demonstrates how to calculate MACD and Stochastic RSI from candle records and plot their values alongside price candles. It describes MACD’s three output series—DIF, DEA, and histogram—and shows how a chart can update the latest bar while adding a newly completed bar. It also explains that indicator outputs may be null until enough historical candles are available, so programs should check input length before using them.

A comparison with an exchange chart finds close agreement for DIF and DEA, while the MACD histogram differs by a factor of two because that chart displays twice the difference between DIF and DEA. The Stochastic RSI example reports a mismatch with the exchange’s values and suggests implementation differences as a possible cause. The examples are for learning and visualization; they do not define trading signals or establish predictive performance. The Stochastic RSI implementation is described as slow and unoptimized.

Key ideas

  • Indicator functions can return invalid or null values until enough candle history is available.
  • The MACD function provides DIF, DEA, and a histogram series for charting.
  • An exchange may scale the MACD histogram differently from a library implementation.
  • Indicator values can be plotted alongside candles and refreshed as bars form.
  • Stochastic RSI values may vary across implementations, so comparisons require checking calculation conventions.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.