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


Java BollingerBandsUpperIndicator类代码示例

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


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

示例1: main

import org.ta4j.core.indicators.bollinger.BollingerBandsUpperIndicator; //导入依赖的package包/类
public static void main(String[] args) {

        /**
         * Getting time series
         */
        TimeSeries series = CsvTicksLoader.loadAppleIncSeries();

        /**
         * Creating indicators
         */
        // Close price
        ClosePriceIndicator closePrice = new ClosePriceIndicator(series);
        EMAIndicator avg14 = new EMAIndicator(closePrice, 14);
        StandardDeviationIndicator sd14 = new StandardDeviationIndicator(closePrice, 14);

        // Bollinger bands
        BollingerBandsMiddleIndicator middleBBand = new BollingerBandsMiddleIndicator(avg14);
        BollingerBandsLowerIndicator lowBBand = new BollingerBandsLowerIndicator(middleBBand, sd14);
        BollingerBandsUpperIndicator upBBand = new BollingerBandsUpperIndicator(middleBBand, sd14);

        /**
         * Building chart dataset
         */
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        dataset.addSeries(buildChartTimeSeries(series, closePrice, "Apple Inc. (AAPL) - NASDAQ GS"));
        dataset.addSeries(buildChartTimeSeries(series, lowBBand, "Low Bollinger Band"));
        dataset.addSeries(buildChartTimeSeries(series, upBBand, "High Bollinger Band"));

        /**
         * Creating the chart
         */
        JFreeChart chart = ChartFactory.createTimeSeriesChart(
                "Apple Inc. 2013 Close Prices", // title
                "Date", // x-axis label
                "Price Per Unit", // y-axis label
                dataset, // data
                true, // create legend?
                true, // generate tooltips?
                false // generate URLs?
                );
        XYPlot plot = (XYPlot) chart.getPlot();
        DateAxis axis = (DateAxis) plot.getDomainAxis();
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));

        /**
         * Displaying the chart
         */
        displayChart(chart);
    }
 
开发者ID:ta4j,项目名称:ta4j,代码行数:50,代码来源:IndicatorsToChart.java

示例2: getStrategy

import org.ta4j.core.indicators.bollinger.BollingerBandsUpperIndicator; //导入依赖的package包/类
public Strategy getStrategy() {
	
	final ClosePriceIndicator closePrice = new ClosePriceIndicator(timeSeries);
	final SMAIndicator sma = new SMAIndicator(closePrice, bbPeriod);
	
	final BollingerBandsMiddleIndicator bbmiddle = new BollingerBandsMiddleIndicator(sma);
	final StandardDeviationIndicator sd = new StandardDeviationIndicator(closePrice, bbPeriod);
	 
	final BollingerBandsUpperIndicator bbup = new BollingerBandsUpperIndicator(bbmiddle, sd, Decimal.valueOf(deviationUp));
	final BollingerBandsUpperIndicator bbdown = new BollingerBandsUpperIndicator(bbmiddle, sd, Decimal.valueOf(deviationDown));

	final Rule buyingRule = new UnderIndicatorRule(closePrice, bbdown);
	final Rule sellingRule = new OverIndicatorRule(closePrice, bbup).or(new StopLossRule(closePrice, Decimal.valueOf(2)));

	final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
	
	return strategy;
}
 
开发者ID:jnidzwetzki,项目名称:crypto-bot,代码行数:19,代码来源:BBreakoutStrategy.java


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