-
Notifications
You must be signed in to change notification settings - Fork 99
/
Bi.cpp
64 lines (61 loc) · 1.85 KB
/
Bi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <fstream>
#include "Bi.h"
#include "KxianChuLi.h"
#include "BiChuLi.h"
using namespace std;
std::vector<float> Bi1(int nCount, std::vector<float> pHigh, std::vector<float> pLow)
{
std::vector<float> pOut(nCount);
KxianChuLi kxianChuLi;
for (int i = 0; i < nCount; i++)
{
kxianChuLi.add(pHigh[i], pLow[i]);
}
for (unsigned int i = 1; i < kxianChuLi.kxianList.size(); i++)
{
if (kxianChuLi.kxianList.at(i - 1).fangXiang != kxianChuLi.kxianList.at(i).fangXiang)
{
if (kxianChuLi.kxianList.at(i - 1).fangXiang == 1)
{
pOut[kxianChuLi.kxianList.at(i - 1).zhongJian] = 1;
}
else if (kxianChuLi.kxianList.at(i - 1).fangXiang == -1)
{
pOut[kxianChuLi.kxianList.at(i - 1).zhongJian] = -1;
}
}
}
if (kxianChuLi.kxianList.back().fangXiang == 1)
{
pOut[kxianChuLi.kxianList.back().zhongJian] = 1;
}
else if (kxianChuLi.kxianList.back().fangXiang == -1)
{
pOut[kxianChuLi.kxianList.back().zhongJian] = -1;
}
return pOut;
}
std::vector<float> Bi2(int nCount, std::vector<float> pHigh, std::vector<float> pLow)
{
std::vector<float> pOut(nCount);
KxianChuLi kxianChuLi;
for (int i = 0; i < nCount; i++)
{
kxianChuLi.add(pHigh[i], pLow[i]);
}
BiChuLi biChuLi;
biChuLi.handle(kxianChuLi.kxianList);
for (vector<Bi>::iterator iter = biChuLi.biList.begin(); iter != biChuLi.biList.end(); iter++)
{
if ((*iter).fangXiang == 1)
{
pOut[(*iter).kxianList.back().zhongJian] = 1;
}
else if ((*iter).fangXiang == -1)
{
pOut[(*iter).kxianList.back().zhongJian] = -1;
}
}
return pOut;
}