Like Grid Aggregate functions, all Window Aggregate C functions take two input sequence iterator arguments, input and interval. The difference in how Window Aggregate functions determine their sliding window interval is described in the Window versus Grid Aggregate page. The result of all Window Aggregate functions is returned in the result sequence as the calculated aggregate for each interval. As with Grid Aggregate functions, the input sequence is split into intervals based on the value of the interval argument (of type
uint8
) which determines the maximum number of elements in the group, though there may be fewer. So the input sequence will be divided into blocks of interval elements on which the operation is performed.The function signatures are of the following form:
MCO_RET mco_seq_window_agg_operation_TYPE(mco_seq_iterator_h result, mco_seq_iterator_h input, mco_size_t interval);where TYPE is one of the types listed in the Analytics Functions page and operation is one of the following:
mco_seq_window_agg_max_TYPE() Returns the result sequence of the same TYPE
with the maximum value for each window of elementsmco_seq_window_agg_min_TYPE() Returns the result sequence of the same TYPE
with the minimum value for each window of elementsmco_seq_window_agg_sum_TYPE() Returns the result sequence of the same TYPE
with the sum of each window of elementsmco_seq_window_agg_avg_TYPE() Returns the double
result sequence with the average of each window of elementsmco_seq_window_agg_var_TYPE() Returns the double
result sequence with the variance of each window of elementsmco_seq_window_agg_var_samp_TYPE() Returns the double
result sequence with the sample variance of each window of elementsmco_seq_window_agg_dev_TYPE() Returns the double
result sequence with the standard deviation of each window of elementsmco_seq_window_agg_dev_samp_TYPE() Returns the double
result sequence with the sample standard deviation of each window of elementsmco_seq_window_agg_ema_TYPE() Returns the double
result sequence with the Exponential Moving Average (EMA) indicator with interval period. Calculates the coefficient of weighting decrease p=2 / (window_size + 1). (Please see the Window_Agg_EMA Function page for a more detailed explanation.)mco_seq_window_agg_atr_TYPE() Returns the double
result sequence with the Average True Range (ATR) indicator withwindow_size
period. (Please see the Window_Agg_ATR Function page for a more detailed explanation.)Example
Following is an example code snippet demonstrating a window aggregate function:
{ mco_trans_h trans; mco_cursor_t quote_cursor; Quote quote; mco_seq_iterator_t close_iterator, max_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_max_float(&max_iterator, &close_iterator, 7); ... } ... }