本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
};
}