当前位置: 首页>>代码示例>>Java>>正文


Java Indicator类代码示例

本文整理汇总了Java中org.ta4j.core.Indicator的典型用法代码示例。如果您正苦于以下问题:Java Indicator类的具体用法?Java Indicator怎么用?Java Indicator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Indicator类属于org.ta4j.core包,在下文中一共展示了Indicator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildChartTimeSeries

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Builds a JFreeChart time series from a Ta4j time series and an indicator.
 * @param tickSeries the ta4j time series
 * @param indicator the indicator
 * @param name the name of the chart time series
 * @return the JFreeChart time series
 */
private static org.jfree.data.time.TimeSeries buildChartTimeSeries(TimeSeries tickSeries, Indicator<Decimal> indicator, String name) {
    org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries(name);
    for (int i = 0; i < tickSeries.getTickCount(); i++) {
        Tick tick = tickSeries.getTick(i);
        chartTimeSeries.add(new Day(Date.from(tick.getEndTime().toInstant())), indicator.getValue(i).toDouble());
    }
    return chartTimeSeries;
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:16,代码来源:IndicatorsToChart.java

示例2: CrossIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param up the upper indicator
 * @param low the lower indicator
 */
public CrossIndicator(Indicator<Decimal> up, Indicator<Decimal> low) {
    // TODO: check if up series is equal to low series
    super(up);
    this.up = up;
    this.low = low;
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:12,代码来源:CrossIndicator.java

示例3: DifferenceIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * (first minus second)
 * @param first the first indicator
 * @param second the second indicator
 */
public DifferenceIndicator(Indicator<Decimal> first, Indicator<Decimal> second) {
    // TODO: check if first series is equal to second one
    super(first);
    this.first = first;
    this.second = second;
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:13,代码来源:DifferenceIndicator.java

示例4: MeanDeviationIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param indicator the indicator
 * @param timeFrame the time frame
 */
public MeanDeviationIndicator(Indicator<Decimal> indicator, int timeFrame) {
    super(indicator);
    this.indicator = indicator;
    this.timeFrame = timeFrame;
    sma = new SMAIndicator(indicator, timeFrame);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:12,代码来源:MeanDeviationIndicator.java

示例5: PPOIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
public PPOIndicator(Indicator<Decimal> indicator, int shortTimeFrame, int longTimeFrame) {
    super(indicator);
    if (shortTimeFrame > longTimeFrame) {
        throw new IllegalArgumentException("Long term period count must be greater than short term period count");
    }
    shortTermEma = new EMAIndicator(indicator, shortTimeFrame);
    longTermEma = new EMAIndicator(indicator, longTimeFrame);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:9,代码来源:PPOIndicator.java

示例6: UlcerIndexIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param indicator the indicator
 * @param timeFrame the time frame
 */
public UlcerIndexIndicator(Indicator<Decimal> indicator, int timeFrame) {
    super(indicator);
    this.indicator = indicator;
    this.timeFrame = timeFrame;
    highestValueInd = new HighestValueIndicator(indicator, timeFrame);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:12,代码来源:UlcerIndexIndicator.java

示例7: EMAIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param indicator an indicator
 * @param timeFrame the EMA time frame
 */
public EMAIndicator(Indicator<Decimal> indicator, int timeFrame) {
    super(indicator);
    this.indicator = indicator;
    this.timeFrame = timeFrame;
    multiplier = Decimal.TWO.dividedBy(Decimal.valueOf(timeFrame + 1));
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:12,代码来源:EMAIndicator.java

示例8: MACDIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
public MACDIndicator(Indicator<Decimal> indicator, int shortTimeFrame, int longTimeFrame) {
    super(indicator);
    if (shortTimeFrame > longTimeFrame) {
        throw new IllegalArgumentException("Long term period count must be greater than short term period count");
    }
    shortTermEma = new EMAIndicator(indicator, shortTimeFrame);
    longTermEma = new EMAIndicator(indicator, longTimeFrame);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:9,代码来源:MACDIndicator.java

示例9: TrailingStopLossIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param indicator an indicator
 * @param stopLossDistance the stop-loss distance (absolute)
 * @param initialStopLossLimit the initial stop-loss limit
 */
public TrailingStopLossIndicator(Indicator<Decimal> indicator, Decimal stopLossDistance, Decimal initialStopLossLimit) {
    super(indicator);
    this.indicator = indicator;
    this.stopLossDistance = stopLossDistance;
    this.stopLossLimit = initialStopLossLimit;
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:13,代码来源:TrailingStopLossIndicator.java

示例10: AroonUpIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * <p>
 * @param series the time series
 * @param maxValueIndicator the indicator for the maximum price (default {@link MaxPriceIndicator})
 * @param timeFrame the time frame
 */
public AroonUpIndicator(TimeSeries series, Indicator<Decimal> maxValueIndicator, int timeFrame) {
    super(series);
    this.timeFrame = timeFrame;
    this.maxValueIndicator = maxValueIndicator;

    // + 1 needed for last possible iteration in loop
    highestMaxPriceIndicator = new HighestValueIndicator(maxValueIndicator, timeFrame+1);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:16,代码来源:AroonUpIndicator.java

示例11: CoppockCurveIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param indicator the indicator (usually close price)
 * @param longRoCTimeFrame the time frame for long term RoC
 * @param shortRoCTimeFrame the time frame for short term RoC
 * @param wmaTimeFrame the time frame (for WMA)
 */
public CoppockCurveIndicator(Indicator<Decimal> indicator, int longRoCTimeFrame, int shortRoCTimeFrame, int wmaTimeFrame) {
    super(indicator);
    SumIndicator sum = new SumIndicator(
            new ROCIndicator(indicator, longRoCTimeFrame),
            new ROCIndicator(indicator, shortRoCTimeFrame)
    );
    wma = new WMAIndicator(sum, wmaTimeFrame);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:16,代码来源:CoppockCurveIndicator.java

示例12: AroonDownIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * <p>
 * @param series the time series
 * @param minValueIndicator the indicator for the maximum price (default {@link MaxPriceIndicator})
 * @param timeFrame the time frame
 */
public AroonDownIndicator(TimeSeries series, Indicator<Decimal> minValueIndicator, int timeFrame) {
    super(series);
    this.timeFrame = timeFrame;
    this.minValueIndicator = minValueIndicator;

    // + 1 needed for last possible iteration in loop
    lowestMinPriceIndicator = new LowestValueIndicator(minValueIndicator, timeFrame+1);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:16,代码来源:AroonDownIndicator.java

示例13: DPOIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 * @param price the price
 * @param timeFrame the time frame
 */
public DPOIndicator(Indicator<Decimal> price, int timeFrame) {
    super(price);
    this.timeFrame = timeFrame;
    timeShift = timeFrame / 2 + 1;
    this.price = price;
    sma = new SMAIndicator(price, this.timeFrame);
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:13,代码来源:DPOIndicator.java

示例14: WilliamsRIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
public WilliamsRIndicator(Indicator<Decimal> indicator, int timeFrame,
        MaxPriceIndicator maxPriceIndicator, MinPriceIndicator minPriceIndicator) {
    super(indicator);
    this.indicator = indicator;
    this.timeFrame = timeFrame;
    this.maxPriceIndicator = maxPriceIndicator;
    this.minPriceIndicator = minPriceIndicator;
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:9,代码来源:WilliamsRIndicator.java

示例15: FisherIndicator

import org.ta4j.core.Indicator; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param price the price indicator (usually {@link MedianPriceIndicator})
 * @param timeFrame the time frame (usually 10)
 * @param alpha the alpha (usually 0.33)
 * @param beta the beta (usually 0.67)
 */
public FisherIndicator(Indicator<Decimal> price, int timeFrame, final Decimal alpha, final Decimal beta) {
    super(price);
    this.price = price;
    final Indicator<Decimal> periodHigh = new HighestValueIndicator(new MaxPriceIndicator(price.getTimeSeries()), timeFrame);
    final Indicator<Decimal> periodLow = new LowestValueIndicator(new MinPriceIndicator(price.getTimeSeries()), timeFrame);
    intermediateValue = new RecursiveCachedIndicator<Decimal>(price) {

        @Override
        protected Decimal calculate(int index) {
            if (index <= 0) {
                return Decimal.ZERO;
            }
            // alpha * 2 * ((price - MinL) / (MaxH - MinL) - 0.5) + beta * prior value
            Decimal currentPrice = FisherIndicator.this.price.getValue(index);
            Decimal minL = periodLow.getValue(index);
            Decimal maxH = periodHigh.getValue(index);
            Decimal firstPart = currentPrice.minus(minL).dividedBy(maxH.min(minL)).minus(ZERO_DOT_FIVE);
            Decimal secondPart = alpha.multipliedBy(Decimal.TWO).multipliedBy(firstPart);
            Decimal value = secondPart.plus(beta.multipliedBy(getValue(index - 1)));
            if (value.isGreaterThan(VALUE_MAX)) {
                value = VALUE_MAX;
            } else if (value.isLessThan(VALUE_MIN)) {
                value = VALUE_MIN;
            }
            return value;
        }
    };
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:37,代码来源:FisherIndicator.java


注:本文中的org.ta4j.core.Indicator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。