0

posted at

updated at

# はじめに

チャートを表示するときに天井、底を表示する転換点を計算してみる。

# 仕様

auカブコム証券のマニュアルの説明のとおりに実装する。

# 実装

1番目は、無条件に1件目を天井として扱う。その際のリバーサル値も天井の値とする。
2番目は、底となる安値を探すか、天井を更新する最新日を探す。

``````		MergeChartInfo_r10 mci0 = chartList.get(0);
boolean bHigh = true;
int highPrice = mci0.highPrice;
int lowPrice = mci0.lowPrice;
double reversal = highPrice;
indicatorList.add(new CalcIndicatorInfo_r10(mci0, highPrice, bHigh ? 1 : -1, reversal, highPrice));
for (int i = 10; i < chartList.size(); i++) {
if (i + 10 >= chartList.size()) {
break;
}
MergeChartInfo_r10 mci = chartList.get(i);
int high0 = mci.highPrice;
int low0 = mci.lowPrice;
int high1 = high0;
int low1 = low0;
int high2 = high1;
int low2 = low1;
for (int j = 1; j <= 10; j++) {
MergeChartInfo_r10 mci1 = chartList.get(i - j);
high1 = Math.max(high1, mci1.highPrice);
low1 = Math.min(low1, mci1.lowPrice);
high2 = Math.max(high2, mci1.highPrice);
low2 = Math.min(low2, mci1.lowPrice);
MergeChartInfo_r10 mci2 = chartList.get(i + j);
high2 = Math.max(high2, mci2.highPrice);
low2 = Math.min(low2, mci2.lowPrice);
}
if (bHigh) {
if (high0 >= high2 && high0 >= highPrice) {
indicatorList.remove(indicatorList.size() - 1);
highPrice = high0;
reversal = highPrice + (low1 - highPrice) * 0.5;
indicatorList.add(new CalcIndicatorInfo_r10(mci, highPrice, bHigh ? 1 : -1, reversal, low1));
} else if (low0 <= low2 && low0 <= reversal) {
bHigh = !bHigh;
lowPrice = low0;
reversal = lowPrice + (high1 - lowPrice) * 0.5;
indicatorList.add(new CalcIndicatorInfo_r10(mci, lowPrice, bHigh ? 1 : -1, reversal, high1));
}
} else {
if (low0 <= low2 && low0 <= lowPrice) {
indicatorList.remove(indicatorList.size() - 1);
lowPrice = low0;
reversal = lowPrice + (high1 - lowPrice) * 0.5;
indicatorList.add(new CalcIndicatorInfo_r10(mci, lowPrice, bHigh ? 1 : -1, reversal, high1));
} else if (high0 >= high2 && high0 >= reversal) {
bHigh = !bHigh;
highPrice = high0;
reversal = highPrice + (low1 - highPrice) * 0.5;
indicatorList.add(new CalcIndicatorInfo_r10(mci, highPrice, bHigh ? 1 : -1, reversal, low1));
}
}
}
``````

## 組み込み

クラスをv38.c.CalcIndicator8_r10を作成し、ファクトリー設定ファイル(CalcIndicatorFactory_r10.properties)に追加する。

``````8=v38.c.CalcIndicator8_r10
``````

# テスト

``````2022/10/06 16:30:00,27220,1,27230,H,27230.00,27230
2022/10/06 16:46:00,27185,1,27170,L,27197.50,27225
2022/10/06 17:07:00,27220,1,27225,H,27205.00,27185
2022/10/06 17:45:00,27120,1,27120,L,27140.00,27160
2022/10/06 17:53:00,27150,1,27155,H,27137.50,27120
2022/10/06 18:04:00,27135,1,27125,L,27137.50,27150
2022/10/06 18:11:00,27155,1,27155,H,27140.00,27125
2022/10/06 18:16:00,27125,1,27125,L,27140.00,27155
2022/10/06 18:33:00,27145,1,27155,H,27147.50,27140
2022/10/06 19:27:00,27065,1,27055,L,27065.00,27075
2022/10/06 19:36:00,27090,1,27090,H,27072.50,27055
2022/10/06 19:45:00,27065,1,27065,L,27077.50,27090
2022/10/06 19:49:00,27075,1,27080,H,27072.50,27065	ng
2022/10/06 19:59:00,27080,1,27070,L,27075.00,27080	ng
2022/10/06 20:09:00,27105,1,27115,H,27092.50,27070
2022/10/06 20:29:00,27090,1,27085,L,27095.00,27105
``````

なぜか19:49と19:59が余計に出てくるが、リバーサル値が27077.5なので27080が天井となるのは間違っていない。。。

# githubソース

Register as a new user and use Qiita more conveniently

1. You get articles that match your needs
2. You can efficiently read back useful information
What you can do with signing up
0