Indicators
This commit is contained in:
parent
804f6ab2bc
commit
d1080165aa
@ -39,6 +39,7 @@
|
||||
<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/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/gui/Statistics.java</file>
|
||||
<file>file:/home/tube/NetBeansProjects/SeSim/src/gui/EditStrategies.java</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.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
|
@ -29,6 +29,7 @@ import chart.painter.CandleStickChartPainter;
|
||||
import chart.painter.ChartPainter;
|
||||
import chart.painter.XLegendPainter;
|
||||
import chart.painter.ChartCrossPainter;
|
||||
import chart.painter.LineChartPainter;
|
||||
import chart.painter.YLegendPainter;
|
||||
import gui.Globals;
|
||||
import sesim.Exchange.QuoteReceiver;
|
||||
@ -63,7 +64,10 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch
|
||||
this.xLegend.setChartDef(chartDef);
|
||||
this.yLegend.setChartDef(chartDef);
|
||||
|
||||
ChartPainter p = new CandleStickChartPainter();
|
||||
ChartPainter p = new LineChartPainter();
|
||||
p.setDataProvider(this);
|
||||
chart.addChartPainter(p);
|
||||
|
||||
this.xScrollBar.setMaximum(0);
|
||||
|
||||
p = new XLegendPainter();
|
||||
|
@ -35,7 +35,9 @@ import sesim.OHLCDataItem;
|
||||
*/
|
||||
public class LineChartPainter extends OHLCChartPainter{
|
||||
|
||||
|
||||
protected float getVal(OHLCDataItem i){
|
||||
return i.getAverage();
|
||||
}
|
||||
|
||||
@Override
|
||||
void drawItem(Graphics2D g, int prevx, int x, OHLCDataItem prev, OHLCDataItem i) {
|
||||
@ -43,8 +45,8 @@ public class LineChartPainter extends OHLCChartPainter{
|
||||
if (prev == null) {
|
||||
prev = i;
|
||||
}
|
||||
int y1 = (int) getY(prev.close);
|
||||
int y2 = (int) getY(i.close);
|
||||
int y1 = (int) getY(getVal(prev));
|
||||
int y2 = (int) getY(getVal(i));
|
||||
Color cur = g.getColor();
|
||||
g.setColor(Color.RED);
|
||||
|
||||
|
@ -30,13 +30,41 @@ package sesim;
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class Indicator {
|
||||
OHLCData parent;
|
||||
private OHLCData parent;
|
||||
|
||||
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){
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user