11 if (macd->len <= macd->start) {
14 double diff = ema_short - ema_long;
16 macd->value = (
WU_MACDResult){.macd = diff, .signal = signal, .histogram = diff - signal};
27WU_MACD
wu_macd_new(
int short_window,
int long_window,
int signal_window,
29 WU_MACD macd = malloc(
sizeof(
struct WU_MACD_));
30 macd->ema_short =
wu_ema_new(short_window, smoothing);
31 macd->ema_long =
wu_ema_new(long_window, smoothing);
32 macd->signal_line =
wu_ema_new(signal_window, smoothing);
35 macd->value = (
WU_MACDResult){.macd = NAN, .signal = NAN, .histogram = NAN};
37 macd->start = long_window > short_window ? long_window : short_window;
#define wu_indicator_delete(indicator)
Delete the indicator and free any resources allocated by it.
WU_EMA wu_ema_new(int window_size, double smoothing)
Creates a new WU_EMA (Exponential Moving Average) indicator with the specified period and smoothing f...
#define wu_indicator_update(indicator, value)
Header file for technical indicators.
static void macd_free(WU_MACD macd)
static WU_MACDResult macd_update(WU_MACD macd, double value)
WU_MACD wu_macd_new(int short_window, int long_window, int signal_window, double smoothing)
Creates a new WU_MACD (Moving Average Convergence Divergence) indicator with the specified short and ...
The WU_MACDResult structure holds the current values of the MACD line, signal line,...
The WU_MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator that show...