hikyuu2/hikyuu_cpp/hikyuu/indicator/crt/DMA.h
2019-06-01 23:54:18 +08:00

41 lines
832 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.

/*
* DMA.h
*
* Copyright (c) 2019, hikyuu.org
*
* Created on: 2015-5-16
* Author: fasiondog
*/
#ifndef INDICATOR_CRT_DMA_H_
#define INDICATOR_CRT_DMA_H_
#include "REF.h"
namespace hku {
/**
* 动态移动平均
* @details
* <pre>
* 用法DMA(X,A),求X的动态移动平均。
* 算法若Y=DMA(X,A) 则 Y=A*X+(1-A)*Y',其中Y'表示上一周期Y值。
* 例如DMA(CLOSE,VOL/CAPITAL)表示求以换手率作平滑因子的平均价
* </pre>
* @param ind 待计算的数据
* @param a 动态系数
* @ingroup Indicator
*/
Indicator DMA(const Indicator& ind1, const Indicator& a);
inline Indicator DMA(const Indicator& ind1, const Indicator& a) {
Indicator dma = a * ind1 + (1 - a) * REF(ind1, 1);
dma.name("DMA");
return dma;
}
} /* namespace */
#endif /* INDICATOR_CRT_DMA_H_ */