select cs_window_max(Close,3) from Quote_get('IBM'); cs_window_max ----------------------------------- float4:{10.5,20.2,30.2,40.2,50.5} (1 row) select cs_window_min(Close,3) from Quote_get('IBM'); cs_window_min ----------------------------- float4:{0,0,10.5,20.2,30.2} (1 row) select cs_window_sum(Close,3) from Quote_get('IBM'); cs_window_sum ----------------------------------------------------------------------------------- float8:{10.5,30.7000007629395,60.9000015258789,90.6000022888184,120.900001525879} (1 row) select cs_window_avg(Close,3) from Quote_get('IBM'); cs_window_avg ---------------------------------------------------------------------------------- float8:{3.5,10.2333335876465,20.3000005086263,30.2000007629395,40.3000005086263} (1 row) select cs_window_var(Close,3) from Quote_get('IBM'); cs_window_var ----------------------------------------------------------------------------------- float8:{24.5,68.0422272915312,64.6866716512046,66.6666666666667,68.6866614786786} (1 row) select cs_window_dev(Close,3) from Quote_get('IBM'); cs_window_dev ----------------------------------------------------------------------------------------------- float8:{4.94974746830583,8.24877125949866,8.04280247495887,8.16496580927726,8.28774163923313} (1 row) --- Leave only elements corresponding to entire window select cs_limit(cs_window_max(Close,3), 2) from Quote_get('IBM'); cs_limit ------------------------- float4:{30.2,40.2,50.5} (1 row) select cs_window_min(Close,3) << 2 from Quote_get('IBM'); ?column? ------------------------- float4:{10.5,20.2,30.2} (1 row) select cs_window_sum(Close,3) << 2 from Quote_get('IBM'); ?column? ------------------------------------------------------------- float8:{60.9000015258789,90.6000022888184,120.900001525879} (1 row) select cs_window_avg(Close,3) << 2 from Quote_get('IBM'); ?column? ------------------------------------------------------------- float8:{20.3000005086263,30.2000007629395,40.3000005086263} (1 row) select cs_window_var(Close,3) << 2 from Quote_get('IBM'); ?column? ------------------------------------------------------------- float8:{64.6866716512046,66.6666666666667,68.6866614786786} (1 row) select cs_window_dev(Close,3) << 2 from Quote_get('IBM'); ?column? ------------------------------------------------------------- float8:{8.04280247495887,8.16496580927726,8.28774163923313} (1 row) --- 2-days EMA (Exponential Moving Average) select cs_window_ema(Close,3) from Quote_get('IBM'); cs_window_ema --------------------------------------------------------------------------------- float8:{10.5,15.3500003814697,22.7750005722046,31.487500667572,40.993750333786} (1 row) --- 2-days ATR (Average True Range) select cs_window_atr(cs_maxof(High-Low,cs_concat('float4:{0}',cs_maxof(cs_abs((High<<1) - Close), cs_abs((Low<<1) - Close)))), 3) << 2 from Quote_get('IBM'); ?column? ------------------------------------------------------------- float8:{7.16666666666667,8.37777752346463,9.18518476132993} (1 row)