Skip to content

Commit

Permalink
fixed LLV/LLVBARS/HHVBARS
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Nov 29, 2021
1 parent 33fc746 commit 8389773
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 46 deletions.
29 changes: 13 additions & 16 deletions hikyuu_cpp/hikyuu/indicator/imp/IHhvbars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,26 @@ void IHhvbars::_calculate(const Indicator& ind) {
_set(i - pre_pos, i);
}

for (size_t i = start_pos; i < total - 1; i++) {
for (size_t i = start_pos; i < total; i++) {
size_t j = i + 1 - n;
if (pre_pos < j) {
pre_pos = j;
max = ind[j];
}
if (ind[i] >= max) {
max = ind[i];
pre_pos = i;
}
_set(i - pre_pos, i);
}
for (size_t j = pre_pos + 1; j <= i; j++) {
if (ind[j] >= max) {
max = ind[j];
pre_pos = j;
}
}

start_pos = total - n;
max = ind[start_pos];
pre_pos = start_pos;
for (size_t i = start_pos; i < total; i++) {
if (ind[i] >= max) {
pre_pos = i;
max = ind[i];
} else {
if (ind[i] >= max) {
max = ind[i];
pre_pos = i;
}
}
_set(i - pre_pos, i);
}
_set(total - pre_pos - 1, total - 1);
}

Indicator HKU_API HHVBARS(int n) {
Expand Down
2 changes: 1 addition & 1 deletion hikyuu_cpp/hikyuu/indicator/imp/IHighLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void IHighLine::_calculate(const Indicator& ind) {
pre_pos = j;
max = ind[j];
for (size_t j = pre_pos + 1; j <= i; j++) {
if (ind[j] > max) {
if (ind[j] >= max) {
max = ind[j];
pre_pos = j;
}
Expand Down
24 changes: 11 additions & 13 deletions hikyuu_cpp/hikyuu/indicator/imp/ILowLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,20 @@ void ILowLine::_calculate(const Indicator& ind) {
if (pre_pos < j) {
pre_pos = j;
min = ind[j];
}
if (ind[i] <= min) {
min = ind[i];
pre_pos = i;
for (size_t j = pre_pos + 1; j <= i; j++) {
if (ind[j] <= min) {
min = ind[j];
pre_pos = j;
}
}
} else {
if (ind[i] <= min) {
min = ind[i];
pre_pos = i;
}
}
_set(min, i);
}

startPos = total - n;
min = ind[startPos];
for (size_t i = startPos; i < total; i++) {
if (ind[i] <= min) {
min = ind[i];
}
}
_set(min, total - 1);
}

Indicator HKU_API LLV(int n = 20) {
Expand Down
28 changes: 12 additions & 16 deletions hikyuu_cpp/hikyuu/indicator/imp/ILowLineBars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,25 @@ void ILowLineBars::_calculate(const Indicator& ind) {
_set(i - pre_pos, i);
}

for (size_t i = start_pos; i < total - 1; i++) {
for (size_t i = start_pos; i < total; i++) {
size_t j = i + 1 - n;
if (pre_pos < j) {
pre_pos = j;
min = ind[j];
}
if (ind[i] <= min) {
min = ind[i];
pre_pos = i;
for (size_t j = pre_pos + 1; j <= i; j++) {
if (ind[j] <= min) {
min = ind[j];
pre_pos = j;
}
}
} else {
if (ind[i] <= min) {
min = ind[i];
pre_pos = i;
}
}
_set(i - pre_pos, i);
}

start_pos = total - n;
min = ind[start_pos];
pre_pos = start_pos;
for (size_t i = start_pos; i < total; i++) {
if (ind[i] <= min) {
pre_pos = i;
min = ind[i];
}
}
_set(total - pre_pos - 1, total - 1);
}

Indicator HKU_API LLVBARS(int n) {
Expand Down
3 changes: 3 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set_xmakever("2.5.4")
set_project("hikyuu")

add_rules("mode.debug", "mode.release")
if not is_plat("windows") then
add_rules("mode.coverage")
end

-- version
set_version("1.1.9", {build="%Y%m%d%H%M"})
Expand Down

0 comments on commit 8389773

Please sign in to comment.