hikyuu2/hikyuu_cpp/hikyuu/indicator/crt/BETWEEN.h

86 lines
2.7 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.

/*
* BETWEEN.h
*
* Created on: 2019年4月8日
* Author: fasiondog
*/
#ifndef INDICATOR_CRT_BETWEEN_H_
#define INDICATOR_CRT_BETWEEN_H_
#include "CVAL.h"
namespace hku {
/**
* 介于(介于两个数之间)
* @details
* <pre>
* 用法BETWEEN(A,B,C)表示A处于B和C之间时返回1否则返回0
* 例如BETWEEN(CLOSE,MA(CLOSE,10),MA(CLOSE,5))表示收盘价介于5日均线和10日均线之间
* @ingroup Indicator
* </pre>
*/
Indicator BETWEEN(const Indicator&, const Indicator&, const Indicator&);
Indicator BETWEEN(const Indicator&, const Indicator&, price_t);
Indicator BETWEEN(const Indicator&, price_t, const Indicator&);
Indicator BETWEEN(const Indicator&, price_t, price_t);
Indicator BETWEEN(price_t, const Indicator&, const Indicator&);
Indicator BETWEEN(price_t, const Indicator&, price_t);
Indicator BETWEEN(price_t, price_t, const Indicator&);
Indicator BETWEEN(price_t, price_t, price_t);
inline Indicator BETWEEN(const Indicator& a, const Indicator& b, const Indicator& c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(const Indicator& a, const Indicator& b, price_t c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(const Indicator& a, price_t b, const Indicator& c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(const Indicator& a, price_t b, price_t c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(price_t a, const Indicator& b, const Indicator& c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(price_t a, const Indicator& b, price_t c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(price_t a, price_t b, const Indicator& c) {
Indicator result = IF(((b > c) & (a < b) & (a > c)) | ((b < c) & (a > b) & (a < c)), 1, 0);
result.name("BETWEEN");
return result;
}
inline Indicator BETWEEN(price_t a, price_t b, price_t c) {
Indicator result = CVAL((((b > c) && (a < b) && (a > c)) || ((b < c) && (a > b) && (a < c))) ? 1 : 0);
result.name("BETWEEN");
return result;
}
}
#endif /* INDICATOR_CRT_BETWEEN_H_ */