SMA Indicator

This commit is contained in:
7u83 2017-11-17 21:36:11 +01:00
parent fda75cbff8
commit 1858a65fe6
5 changed files with 41 additions and 27 deletions

View File

@ -44,7 +44,6 @@
<file>file:/home/tube/NetBeansProjects/SeSim/src/gui/Statistics.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/gui/Statistics.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditStrategies.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditStrategies.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/chart/Chart.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/Clock.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/IDGenerator.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/IDGenerator.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderGui.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderGui.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/gui/jp99.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/gui/jp99.java</file>

View File

@ -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=true
annotation.processing.enabled.in.editor=false annotation.processing.enabled.in.editor=false
annotation.processing.processors.list= annotation.processing.processors.list=

View File

@ -61,17 +61,26 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch
Globals.se.addQuoteReceiver(this); Globals.se.addQuoteReceiver(this);
Indicator in = new SMAIndicator(get());
this.chart.setChartDef(chartDef); this.chart.setChartDef(chartDef);
this.xLegend.setChartDef(chartDef); this.xLegend.setChartDef(chartDef);
this.yLegend.setChartDef(chartDef); this.yLegend.setChartDef(chartDef);
ChartPainter p = new LineChartPainter(); class SMA implements ChartPainter.DataProvider {
p.setDataProvider(this);
chart.addChartPainter(p); SMAIndicator sma;
SMA(OHLCData data){
sma = new SMAIndicator(data);
}
@Override
public OHLCData get() {
return sma.getData();
}
}
ChartPainter p;
this.xScrollBar.setMaximum(0); this.xScrollBar.setMaximum(0);
@ -88,20 +97,19 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch
chart.setXSCrollBar(xScrollBar); chart.setXSCrollBar(xScrollBar);
chart.addChartPainter(new ChartCrossPainter()); 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); ChartPainter yp = new YLegendPainter(chart);
yp.setDataProvider(this); yp.setDataProvider(this);
this.yLegend.addChartPainter(yp); this.yLegend.addChartPainter(yp);
// this.yLegend.addChartPainter(p); // this.yLegend.addChartPainter(p);
//this.yLegend.addChartPainter(pc); //this.yLegend.addChartPainter(pc);
} }
/** /**

View File

@ -211,6 +211,11 @@ public class Exchange {
} }
public void addIndicator(Indicator i){
this.indicators.add(i);
}
public void createTraders(JSONArray traderdefs) { public void createTraders(JSONArray traderdefs) {
for (int i = 0; i < traderdefs.length(); i++) { for (int i = 0; i < traderdefs.length(); i++) {

View File

@ -61,8 +61,10 @@ public class SMAIndicator implements Indicator {
} }
void update(){ 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); OHLCDataItem p = parent.get(i);
float pr = this.getAt(i); float pr = this.getAt(i);
@ -74,7 +76,7 @@ public class SMAIndicator implements Indicator {
} }
} }
OHLCData getData(){ public OHLCData getData(){
update(); update();
return indicator; return indicator;