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

46 lines
965 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.

/*
* LAST.h
*
* Copyright (c) 2019 hikyuu.org
*
* Created on: 2019-4-28
* Author: fasiondog
*/
#pragma once
#ifndef INDICATOR_CRT_LAST_H_
#define INDICATOR_CRT_LAST_H_
#include "EVERY.h"
#include "REF.h"
namespace hku {
/**
* 区间存在
* @details
* <pre>
* 用法LAST (X,M,N) 表示条件X在前M周期到前N周期存在
* 例如LAST(CLOSE>OPEN,10,5) 表示从前10日到前5日内一直阳线。若A为0,表示从第一天开始,B为0,表示到最后日止。
* </pre>
* @ingroup Indicator
*/
Indicator LAST(int m=10, int n=5);
Indicator LAST(const Indicator& ind, int m=10, int n=5);
inline Indicator LAST(int m, int n) {
int max = std::max(m,n);
int min = std::min(m,n);
Indicator result = REF(EVERY(max-min+1), min);
result.name("LAST");
return result;
}
inline Indicator LAST(const Indicator& ind, int m, int n) {
return LAST(m, n)(ind);
}
} /* namespace */
#endif /* INDICATOR_CRT_LAST_H_ */