SMAIndicator works

This commit is contained in:
7u83 2017-11-17 23:09:06 +01:00
parent 1858a65fe6
commit 3e19afbe25
4 changed files with 26 additions and 8 deletions

View File

@ -1,4 +1,4 @@
#Fri, 17 Nov 2017 21:34:44 +0100 #Fri, 17 Nov 2017 23:03:13 +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

@ -255,7 +255,7 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver, Ch
@Override @Override
public OHLCData get() { public OHLCData get() {
return Globals.se.getOHLCdata(60000 * 60); return Globals.se.getOHLCdata(60000 * 10);
} }
} }

View File

@ -149,6 +149,10 @@ public class OHLCData {
data.set(n,item); data.set(n,item);
} }
public void add(OHLCDataItem item){
data.add(item);
}
private void updateMinMax(float price) { private void updateMinMax(float price) {
if (price > max) { if (price > max) {

View File

@ -25,6 +25,8 @@
*/ */
package sesim; package sesim;
import gui.Globals;
/** /**
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
@ -36,9 +38,10 @@ public class SMAIndicator implements Indicator {
public SMAIndicator(OHLCData parent){ public SMAIndicator(OHLCData parent){
this.parent=parent; this.parent=parent;
indicator = new OHLCData();
} }
int len=10; int len=30;
float getAt(int pos){ float getAt(int pos){
if (parent.size()==0) if (parent.size()==0)
@ -50,7 +53,8 @@ public class SMAIndicator implements Indicator {
start=0; start=0;
float sum=0; float sum=0;
for (int i=start; i<pos; i++){ for (int i=start; i<pos; i++){
sum += parent.get(i).getAverage(); //sum += parent.get(i).getAverage();
sum += parent.get(i).close;
} }
if (pos-start==0){ if (pos-start==0){
@ -61,16 +65,26 @@ public class SMAIndicator implements Indicator {
} }
void update(){ void update(){
parent = Globals.se.getOHLCdata(60000 * 10);
if (parent.size()==0) if (parent.size()==0)
return; return;
for (int i = parent.size()-1;i<0;i++){ /* if (parent.size()==indicator.size()){
int i=parent.size()-1;
OHLCDataItem p = parent.get(i); OHLCDataItem p = parent.get(i);
float pr = this.getAt(i); float pr = this.getAt(i);
OHLCDataItem it = new sesim.OHLCDataItem(p.time, pr, 0); OHLCDataItem it = new sesim.OHLCDataItem(p.time, pr, 0);
this.indicator.set(i, it); return;
}
*/
for (int i = indicator.size();i<parent.size();i++){
OHLCDataItem p = parent.get(i);
float pr = this.getAt(i);
OHLCDataItem it = new sesim.OHLCDataItem(p.time, pr, 0);
this.indicator.add(it);
} }