예제 #1
0
        public static void Main(string[] args)
        {
            /// <summary>
            /// Getting time series
            /// </summary>
            TimeSeries series = CsvTradesLoader.loadBitstampSeries().subseries(0, Period.hours(6));

            /// <summary>
            /// Creating the OHLC dataset
            /// </summary>
            OHLCDataset ohlcDataset = createOHLCDataset(series);

            /// <summary>
            /// Creating the additional dataset
            /// </summary>
            TimeSeriesCollection xyDataset = createAdditionalDataset(series);

            /// <summary>
            /// Creating the chart
            /// </summary>
            JFreeChart chart = ChartFactory.createCandlestickChart("Bitstamp BTC price", "Time", "USD", ohlcDataset, true);
            // Candlestick rendering
            CandlestickRenderer renderer = new CandlestickRenderer();

            renderer.AutoWidthMethod = CandlestickRenderer.WIDTHMETHOD_SMALLEST;
            XYPlot plot = chart.XYPlot;

            plot.Renderer = renderer;
            // Additional dataset
            int index = 1;

            plot.setDataset(index, xyDataset);
            plot.mapDatasetToRangeAxis(index, 0);
            XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);

            renderer2.setSeriesPaint(index, Color.blue);
            plot.setRenderer(index, renderer2);
            // Misc
            plot.RangeGridlinePaint = Color.lightGray;
            plot.BackgroundPaint    = Color.white;
            NumberAxis numberAxis = (NumberAxis)plot.RangeAxis;

            numberAxis.AutoRangeIncludesZero = false;
            plot.DatasetRenderingOrder       = DatasetRenderingOrder.FORWARD;

            /// <summary>
            /// Displaying the chart
            /// </summary>
            displayChart(chart);
        }