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/EditStrategies.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/AutoTraderGui.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.in.editor=false
annotation.processing.processors.list=

View File

@ -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
}// </editor-fold>//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

View File

@ -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++) {

View File

@ -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;