Imroved Indicator interface, draws two indicators now
This commit is contained in:
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user