hikyuu2/hikyuu_cpp/hikyuu/indicator/crt/MAX.h
2019-11-10 23:31:41 +08:00

50 lines
1.1 KiB
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.

/*
* MAX.h
*
* Created on: 2019年4月8日
* Author: fasiondog
*/
#pragma once
#ifndef INDICATOR_CRT_MAX_H_
#define INDICATOR_CRT_MAX_H_
#include "CVAL.h"
namespace hku {
/**
* 求最大值
* @details
* <pre>
* 用法: MAX(A,B)返回A和B中的较大值
* 例如: MAX(CLOSE-OPEN,0)表示若收盘价大于开盘价返回它们的差值否则返回0
* </pre>
* @ingroup Indicator
*/
Indicator MAX(const Indicator&, const Indicator&);
Indicator MAX(const Indicator&, price_t val);
Indicator MAX(price_t val, const Indicator& ind);
inline Indicator MAX(const Indicator& ind1, const Indicator& ind2) {
Indicator result = IF(ind1 > ind2, ind1, ind2);
result.name("MAX");
return result;
}
inline Indicator MAX(const Indicator& ind, price_t val) {
Indicator result = IF(ind > val, ind, val);
result.name("MAX");
return result;
}
inline Indicator MAX(price_t val, const Indicator& ind) {
Indicator result = IF(val > ind, val, ind);
result.name("MAX");
return result;
}
} // namespace hku
#endif /* INDICATOR_CRT_MAX_H_ */