Imroved Indicator interface, draws two indicators now

This commit is contained in:
2017-11-25 09:28:01 +01:00
parent ff0e8bc4b9
commit f6eab6b6a2
7 changed files with 95 additions and 33 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, tube
* Copyright (c) 2017, 7u83
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -26,13 +26,14 @@
package indicators;
import org.json.JSONObject;
import sesim.ConfigurableInterface;
import sesim.Indicator;
/**
*
* @author tube
*/
public abstract class BaseIndicator implements Indicator{
public abstract class BaseIndicator implements Indicator {
@Override
public String getName() {

View File

@ -25,6 +25,7 @@
*/
package indicators;
import org.json.JSONObject;
import sesim.OHLCData;
import sesim.OHLCDataItem;
@ -38,16 +39,31 @@ public class SMAIndicator extends BaseIndicator {
OHLCData indicator;
public SMAIndicator(OHLCData parent) {
this.parent = parent;
public SMAIndicator() {
indicator = new OHLCData();
}
public void setParent(OHLCData parent){
public void setParent(OHLCData parent) {
this.parent = parent;
}
int len = 20;
final String LEN = "len";
int len = 60;
@Override
public void putConfig(JSONObject cfg) {
len = cfg.getInt(LEN);
}
@Override
public JSONObject getConfig() {
JSONObject r;
r = new JSONObject();
r.put(LEN, len);
return r;
}
private float getAt(int pos) {
if (parent.size() == 0) {
@ -67,10 +83,9 @@ public class SMAIndicator extends BaseIndicator {
}
public void update() {
if (parent.size() == 0) {
return;
}