第四部分、常用到的bar数据元素数组调用【正序版,适合做中间变量计算用】
  
- UID
- 2
- 积分
- 2954160
- 威望
- 1427117 布
- 龙e币
- 1527043 刀
- 在线时间
- 13879 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-5-13

|
第四部分、常用到的bar数据元素数组调用【正序版,适合做中间变量计算用】
头文件声明变量:- //bar常用基本元素调用(开始)【返回正序数组变量】
- vector<double>SeriesClose(); //数组型close价格(返回正序数组形式)
- vector<double>SeriesOpen();//数组型open价格(返回正序数组形式)
- vector<double>SeriesHigh();//数组型最高价high(返回正序数组形式)
- vector<double>SeriesLow();//数组型最低价low(返回正序数组形式)
- vector<double>SeriesMedian();//数组型(high+low)/2(返回正序数组形式)
- vector<double>SeriesAvgPrice();//数组型(high+low+open+close)*0.25(返回正序数组形式)
- vector<double>SeriesOpenInterest();//数组型持仓量(返回正序数组形式)
- vector<double>SeriesVolume();//数组型成交量(返回正序数组形式)
- //bar常用基本元素调用(结束)【返回正序数组变量】
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|
|
|
|
|
|
  
- UID
- 2
- 积分
- 2954160
- 威望
- 1427117 布
- 龙e币
- 1527043 刀
- 在线时间
- 13879 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-5-13

|
公式模块增加:- //第四类函数(常用到的bar数据元素计算函数,正序版,适合做中间变量计算用)
- //数组型close价格(返回正序数组形式)
- vector<double> test::SeriesClose()
- {
- vector<double>newclose;
- newclose.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newclose.push_back(it->second.dClose);//将交易周期bar的收盘价存入newclose容器变量
- }
- vector<double> newclose1;
- return newclose;
- }
- //数组型open价格(返回正序数组形式)
- vector<double> test::SeriesOpen()
- {
- vector<double>newopen;
- newopen.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newopen.push_back(it->second.dOpen);//将交易周期bar的收盘价存入newopen容器变量
- }
- return newopen;
- }
- //数组型最高价high(返回正序数组形式)
- vector<double> test::SeriesHigh()
- {
- vector<double>newhigh;
- newhigh.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newhigh.push_back(it->second.dHigh);//将交易周期bar的最高价存入newhigh容器变量
- }
- return newhigh;
- }
- //数组型最低价low(返回正序数组形式)
- vector<double> test::SeriesLow()
- {
- vector<double>newlow;
- newlow.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newlow.push_back(it->second.dLow);//将交易周期bar的最低价存入newlow容器变量
- }
- return newlow;
- }
- //Median 数组型(high+low)/2(返回正序数组形式)
- vector<double> test::SeriesMedian()
- {
- vector<double>newmedian;// 声明中间容器变量
- newmedian.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newmedian.push_back((it->second.dHigh + it->second.dLow) / 2);//将当根bar的(high+low)/2 存入新容器变量
- }
- return newmedian;
- }
- //数组型(high+low+open+close)*0.25(返回正序数组形式)
- vector<double> test::SeriesAvgPrice()
- {
- vector<double>newv;
- newv.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newv.push_back((it->second.dHigh + it->second.dLow + it->second.dOpen + it->second.dClose) * 0.25);//将当根bar的(high+low)/2 存入新容器变量
- }
- return newv;
- }
- //数组型持仓量(返回正序数组形式)
- vector<double> test::SeriesOpenInterest()
- {
- vector<double>newOpenInterest;
- newOpenInterest.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newOpenInterest.push_back(it->second.nOpenInterest);//将当根bar的持仓量存入新容器变量
- }
- return newOpenInterest;
- }
- //数组型成交量(返回正序数组形式)
- vector<double> test::SeriesVolume()
- {
- vector<double>newvolume;
- newvolume.clear();
- RsqBar(sPeriod, sInst);
- map<string, TKVALUE>::iterator it;//迭代
- for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++) //遍历所有K线
- {
- newvolume.push_back(it->second.nVolume);//将当根bar的成交量存入新容器变量
- }
- return newvolume;
- }
- //第四类函数(常用到的bar数据元素计算函数,正序版,适合做中间变量计算用)
复制代码 |
|
|
|
|
|
|