📄 periodhigh.java
字号:
package com.jsystemtrader.indicator;
import com.jsystemtrader.platform.*;
/**
* Highest high of the period.
*/
public class PeriodHigh extends Indicator {
private final int periodStart, periodEnd;
public PeriodHigh(long time, QuoteHistory qh, int periodStart, int periodEnd) {
super(time, qh);
this.periodStart = periodStart;
this.periodEnd = periodEnd;
}
public double calculate() throws IndicatorCalculationException {
if (periodStart < 0) {
throw new IndicatorCalculationException("Period start must be greater or equal to 0.");
}
if (periodEnd > qh.size() - 1) {
throw new IndicatorCalculationException("Period end exceeds the length of quote history.");
}
double high = qh.getPriceBar(periodStart).getHigh();
for (int bar = periodStart + 1; bar <= periodEnd; bar++) {
double barHigh = qh.getPriceBar(bar).getHigh();
if (barHigh > high) {
high = barHigh;
}
}
value = high;
return value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -