Add moving average to candle stick
Posted: Fri Oct 31, 2014 9:25 pm
I'm trying to add a moving average to a candlestick chart. It should be simple, but doesn't seem to work.
This draw a blue line, but it seems to be an average, not a moving average. It does not lag the candle price, but just connect the average price in each candle?
Help pls.
Code: Select all
JFreeChart chart = ChartFactory.createCandlestickChart(title, "date", "price", dataSet, true);
XYPlot xyplot = (XYPlot)chart.getPlot();
xyplot.setRangeAxis(1, new NumberAxis("Value 1"));
XYDataset xydataset = MovingAverage.createMovingAverage(dataSet, "-MA5", 50, 0);
xyplot.setDataset(1, xydataset);
xyplot.setRenderer(1, new StandardXYItemRenderer());
Help pls.