/// <summary> /// Builds a JFreeChart time series from a Ta4j time series and an indicator. </summary> /// <param name="tickSeries"> the ta4j time series </param> /// <param name="indicator"> the indicator </param> /// <param name="name"> the name of the chart time series </param> /// <returns> the JFreeChart time series </returns> 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.TickCount; i++) { Tick tick = tickSeries.getTick(i); chartTimeSeries.add(new Minute(tick.EndTime.toDate()), indicator.getValue(i).toDouble()); } return(chartTimeSeries); }
/// <summary> /// Builds an additional JFreeChart dataset from a ta4j time series. </summary> /// <param name="series"> a time series </param> /// <returns> an additional dataset </returns> private static TimeSeriesCollection createAdditionalDataset(TimeSeries series) { ClosePriceIndicator indicator = new ClosePriceIndicator(series); TimeSeriesCollection dataset = new TimeSeriesCollection(); org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries("Btc price"); for (int i = 0; i < series.TickCount; i++) { Tick tick = series.getTick(i); chartTimeSeries.add(new Second(tick.EndTime.toDate()), indicator.getValue(i).toDouble()); } dataset.addSeries(chartTimeSeries); return(dataset); }