hikyuu2/hikyuu_cpp/hikyuu/indicator/crt/CROSS.h
2019-05-02 19:41:58 +08:00

48 lines
1015 B
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

/*
* CROSS.h
*
* Copyright (c) 2019 hikyuu.org
*
* Created on: 2019-5-2
* Author: fasiondog
*/
#ifndef INDICATOR_CRT_CROSS_H_
#define INDICATOR_CRT_CROSS_H_
#include "CVAL.h"
#include "REF.h"
namespace hku {
/**
* 两条线交叉, CROSS(AB) 表示当A从下方向上穿过B时返回1否则返回0。
* @ingroup Indicator
*/
Indicator CROSS(const Indicator& x, const Indicator& y);
Indicator CROSS(const Indicator& x, price_t);
Indicator CROSS(price_t, const Indicator& y);
Indicator CROSS(price_t, price_t);
inline Indicator CROSS(const Indicator& x, const Indicator& y) {
Indicator result = (REF(x, 1) < REF(y, 1)) & (x > y);
result.name("CROSS");
return result;
}
Indicator CROSS(const Indicator& x, price_t y) {
return CROSS(x, CVAL(x, y));
}
Indicator CROSS(price_t x, const Indicator& y) {
return CROSS(CVAL(y, x), y);
}
Indicator CROSS(price_t x, price_t y) {
return CROSS(CVAL(x), CVAL(y));
}
} /* namespace */
#endif /* INDICATOR_CRT_NDAY_H_ */