📄 indicators.cpp
字号:
#include "tseries.h"#include "sunhack.h"template<class DateT>tseries<DateT> tseries<DateT>::true_high() const { double *high = getCol("high"); double *close = getCol("close"); if(high==NULL||close==NULL) return tseries(); double *ans_data = new double[rows]; DateT *ans_dates = new DateT[rows]; if(ans_data==NULL || ans_dates==NULL) { cerr << "ERROR: tseries tseries::true_high() out of memory." << endl; return tseries(); } // create dates of new tseries memcpy(ans_dates,getDates(),sizeof(double)*rows); ans_data[0] = NAN; for(unsigned int i = 1; i < rows; i++) ans_data[i] = (high[i] > close[i-1]) ? high[i] : close[i-1]; return tseries(ans_data,ans_dates,rows,1,true);}template<class DateT>tseries<DateT> tseries<DateT>::true_low() const { double *low = getCol("low"); double *close = getCol("close"); if(low==NULL||close==NULL) return tseries(); double *ans_data = new double[rows]; DateT *ans_dates = new DateT[rows]; if(ans_data==NULL || ans_dates==NULL) { cerr << "ERROR: tseries tseries::true_low() out of memory." << endl; return tseries(); } // create dates of new tseries memcpy(ans_dates,getDates(),sizeof(double)*rows); ans_data[0] = NAN; for(unsigned int i = 1; i < rows; i++) ans_data[i] = (low[i] < close[i-1]) ? low[i] : close[i-1]; return tseries(ans_data,ans_dates,rows,1,true);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -