Indicators

This commit is contained in:
7u83 2017-10-23 07:29:42 +02:00
parent 804f6ab2bc
commit d1080165aa
5 changed files with 41 additions and 6 deletions

View File

@ -39,6 +39,7 @@
<file>file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderB.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/traders/RandomTraderB.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/Logger.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/Logger.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditPreferencesDialog.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditPreferencesDialog.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/Indicator.java</file>
<file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderBase.java</file> <file>file:/home/tube/NetBeansProjects/SeSim/src/sesim/AutoTraderBase.java</file>
<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>

View File

@ -1,4 +1,4 @@
#Mon, 16 Oct 2017 20:12:31 +0200 #Sun, 22 Oct 2017 07:44:50 +0200
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

@ -29,6 +29,7 @@ import chart.painter.CandleStickChartPainter;
import chart.painter.ChartPainter; import chart.painter.ChartPainter;
import chart.painter.XLegendPainter; import chart.painter.XLegendPainter;
import chart.painter.ChartCrossPainter; import chart.painter.ChartCrossPainter;
import chart.painter.LineChartPainter;
import chart.painter.YLegendPainter; import chart.painter.YLegendPainter;
import gui.Globals; import gui.Globals;
import sesim.Exchange.QuoteReceiver; import sesim.Exchange.QuoteReceiver;
@ -63,7 +64,10 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch
this.xLegend.setChartDef(chartDef); this.xLegend.setChartDef(chartDef);
this.yLegend.setChartDef(chartDef); this.yLegend.setChartDef(chartDef);
ChartPainter p = new CandleStickChartPainter(); ChartPainter p = new LineChartPainter();
p.setDataProvider(this);
chart.addChartPainter(p);
this.xScrollBar.setMaximum(0); this.xScrollBar.setMaximum(0);
p = new XLegendPainter(); p = new XLegendPainter();

View File

@ -35,7 +35,9 @@ import sesim.OHLCDataItem;
*/ */
public class LineChartPainter extends OHLCChartPainter{ public class LineChartPainter extends OHLCChartPainter{
protected float getVal(OHLCDataItem i){
return i.getAverage();
}
@Override @Override
void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) { void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
@ -43,8 +45,8 @@ public class LineChartPainter extends OHLCChartPainter{
if (prev == null) { if (prev == null) {
prev = i; prev = i;
} }
int y1 = (int) getY(prev.close); int y1 = (int) getY(getVal(prev));
int y2 = (int) getY(i.close); int y2 = (int) getY(getVal(i));
Color cur = g.getColor(); Color cur = g.getColor();
g.setColor(Color.RED); g.setColor(Color.RED);

View File

@ -30,13 +30,41 @@ package sesim;
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class Indicator { public class Indicator {
OHLCData parent; private OHLCData parent;
OHLCData indicator; OHLCData indicator;
Indicator(OHLCData parent){
this.parent=parent;
}
int len=10;
float getAt(int pos){
int start = pos -len;
if(start<0)
start=0;
float sum=0;
for (int i=start; i<pos; i++){
sum += parent.get(i).close;
}
if (pos-start==0){
return 0;
}
return sum/(start-pos);
}
OHLCData getData(int pos){ OHLCData getData(int pos){
return null; return null;
} }
} }