hikyuu2/hikyuu_cpp/hikyuu/indicator/crt/SMA.h
2019-08-03 15:14:39 +08:00

39 lines
730 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SMA.h
*
* Created on: 2015年2月16日
* Author: fasiondog
*/
#ifndef INDICATOR_CRT_SMA_H_
#define INDICATOR_CRT_SMA_H_
#include "../Indicator.h"
namespace hku {
/**
* 求移动平均
* @details
* <pre>
* 用法若Y=SMA(X,N,M) 则 Y=[M*X+(N-M)*Y')/N,其中Y'表示上一周期Y值
* </pre>
* @param data 待计算的数据
* @param n 计算均值的周期窗口必须为大于0的整数
* @param m 系数
* @ingroup Indicator
*/
Indicator SMA(const Indicator& data, int n = 22, double m = 2.0);
Indicator HKU_API SMA(int n = 22, double m = 2.0);
inline Indicator SMA(const Indicator& ind, int n, double m){
return SMA(n, m)(ind);
}
} /* namespace */
#endif /* INDICATOR_CRT_SMA_H_ */