WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
mstdev.c
Go to the documentation of this file.
1#include <math.h>
2#include "wu/indicators.h"
3
4static double update(WU_MStDev stdev, double value) {
5 if (isnan(value)) {
6 return NAN;
7 }
8 stdev->value = sqrt(wu_indicator_update(stdev->mvar, value));
9 return stdev->value;
10}
11
12static void delete(struct WU_MStDev_ *stdev) {
13 stdev->mvar->delete(stdev->mvar);
14 free(stdev);
15}
16
17WU_MStDev wu_mstdev_new(int window_size, int dof) {
18 WU_MStDev stdev = malloc(sizeof(struct WU_MStDev_));
19 stdev->mvar = wu_mvar_new(window_size, dof);
20 stdev->update = update;
21 stdev->delete = delete;
22 return stdev;
23}
static double update(WU_EMA ema, double value)
Definition ema.c:4
#define wu_indicator_update(indicator, value)
Header file for technical indicators.
Definition indicators.h:41
WU_MVar wu_mvar_new(int window_size, int dof)
Creates a new WU_MVar (Moving Variance) indicator with the specified window size and degree of freedo...
Definition mvar.c:32
static double update(WU_MStDev stdev, double value)
Definition mstdev.c:4
WU_MStDev wu_mstdev_new(int window_size, int dof)
Creates a new WU_MStDev (Moving Standard Deviation) indicator with the specified window size and degr...
Definition mstdev.c:17
The WU_MStDev (Moving Standard Deviation) is an indicator that calculates the standard deviation of t...
Definition indicators.h:141