The Exponential Moving Average (EMA) C API
mco_seq_window_agg_ema_TYPE()calculates the EMA using the algorithm described in the Window Aggregate EMA page.Example
Following is an example code snippet demonstrating this function:
{ mco_trans_h trans; mco_cursor_t quote_cursor; Quote quote; mco_seq_iterator_t close_iterator, ema_iterator; MCO_RET rc; ... for (rc = mco_cursor_first(trans, "e_cursor); rc != MCO_S_CURSOR_END; rc = mco_cursor_next(trans, "e_cursor)) { Quote_from_cursor(trans, "e_cursor, "e); Quote_close_iterator("e, &close_iterator); mco_seq_window_agg_ema_float(&ema_iterator, &close_iterator[0], 7); ... } mco_trans_commit(trans); }