diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index d055cf3..eff42ec 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -44,7 +44,6 @@ file:/home/tube/NetBeansProjects/SeSim/src/gui/Statistics.java file:/home/tube/NetBeansProjects/SeSim/src/gui/EditStrategies.java file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart.java - file:/home/tube/NetBeansProjects/SeSim/src/sesim/Clock.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/IDGenerator.java file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderGui.java file:/home/tube/NetBeansProjects/SeSim/src/gui/jp99.java diff --git a/nbproject/project.properties b/nbproject/project.properties index fcf2b72..f32b1e4 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Mon, 30 Oct 2017 22:01:54 +0100 +#Fri, 17 Nov 2017 21:34:44 +0100 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/chart/MasterChart.java b/src/chart/MasterChart.java index 00b94f3..ecbc510 100644 --- a/src/chart/MasterChart.java +++ b/src/chart/MasterChart.java @@ -45,7 +45,7 @@ import sesim.SMAIndicator; public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, ChartPainter.DataProvider { private ChartDef chartDef; - + /** * Creates new form MasterChart */ @@ -60,19 +60,28 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch } Globals.se.addQuoteReceiver(this); - - - Indicator in = new SMAIndicator(get()); - - + this.chart.setChartDef(chartDef); this.xLegend.setChartDef(chartDef); this.yLegend.setChartDef(chartDef); - ChartPainter p = new LineChartPainter(); - p.setDataProvider(this); - chart.addChartPainter(p); - + class SMA implements ChartPainter.DataProvider { + + SMAIndicator sma; + SMA(OHLCData data){ + sma = new SMAIndicator(data); + } + + @Override + public OHLCData get() { + return sma.getData(); + + } + + } + + ChartPainter p; + this.xScrollBar.setMaximum(0); p = new XLegendPainter(); @@ -88,20 +97,19 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch chart.setXSCrollBar(xScrollBar); chart.addChartPainter(new ChartCrossPainter()); + SMAIndicator sma = new sesim.SMAIndicator(get()); + + p = new LineChartPainter(); + p.setDataProvider(new SMA(get())); + chart.addChartPainter(p); + ChartPainter yp = new YLegendPainter(chart); yp.setDataProvider(this); - - this.yLegend.addChartPainter(yp); - - - - - - - - // this.yLegend.addChartPainter(p); - //this.yLegend.addChartPainter(pc); + this.yLegend.addChartPainter(yp); + + // this.yLegend.addChartPainter(p); + //this.yLegend.addChartPainter(pc); } /** @@ -207,7 +215,7 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch }// //GEN-END:initComponents private void chartMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chartMouseMoved - + }//GEN-LAST:event_chartMouseMoved private void formMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_formMouseWheelMoved @@ -222,7 +230,7 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch } this.invalidate(); - this.repaint(); + this.repaint(); }//GEN-LAST:event_formMouseWheelMoved private void xScrollBarAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {//GEN-FIRST:event_xScrollBarAdjustmentValueChanged diff --git a/src/sesim/Exchange.java b/src/sesim/Exchange.java index 01f64cd..93d889c 100644 --- a/src/sesim/Exchange.java +++ b/src/sesim/Exchange.java @@ -211,6 +211,11 @@ public class Exchange { } + public void addIndicator(Indicator i){ + this.indicators.add(i); + } + + public void createTraders(JSONArray traderdefs) { for (int i = 0; i < traderdefs.length(); i++) { diff --git a/src/sesim/SMAIndicator.java b/src/sesim/SMAIndicator.java index 4ce0c45..1749aa9 100644 --- a/src/sesim/SMAIndicator.java +++ b/src/sesim/SMAIndicator.java @@ -61,8 +61,10 @@ public class SMAIndicator implements Indicator { } void update(){ + if (parent.size()==0) + return; - for (int i = indicator.size()-1;i<0;i++){ + for (int i = parent.size()-1;i<0;i++){ OHLCDataItem p = parent.get(i); float pr = this.getAt(i); @@ -74,7 +76,7 @@ public class SMAIndicator implements Indicator { } } - OHLCData getData(){ + public OHLCData getData(){ update(); return indicator;