⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 periodhigh.java

📁 网上期货交易的外挂原码,可实现自动交易功能,自动添加模块
💻 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 + -