试编程一个指标,竟然不显示,可一切正常啊,请教为什么?
箭头指标在副图,为简化,直接赋值 60, 20 , 用console调试检查一切正常,metainfo显示也正常,怎么就是没箭头显示呢?
代码如下,请教!
package com.dukascopy.indicators;
import java.awt.Color;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.IIndicatorContext;
import com.dukascopy.api.indicators.IIndicatorsProvider;
import com.dukascopy.api.indicators.IndicatorInfo;
import com.dukascopy.api.indicators.IndicatorResult;
import com.dukascopy.api.indicators.InputParameterInfo;
import com.dukascopy.api.indicators.IntegerListDescription;
import com.dukascopy.api.indicators.IntegerRangeDescription;
import com.dukascopy.api.indicators.LevelInfo;
import com.dukascopy.api.indicators.OptInputParameterInfo;
import com.dukascopy.api.indicators.OutputParameterInfo;
public class TryArrowIndicator implements IIndicator {
private IIndicatorsProvider indicatorsProvider;
private IndicatorInfo indicatorInfo;
private InputParameterInfo[] inputParameterInfos;
private OutputParameterInfo[] outputParameterInfos;
private OptInputParameterInfo[] optInputParameterInfos;
private double[][][] inputs = new double[1][][];
private double[][] outputs = new double[2][];
private IConsole console = null;
//初始化
public void onStart(IIndicatorContext context) {
console = context.getConsole();
indicatorsProvider = context.getIndicatorsProvider();
indicatorInfo = new IndicatorInfo("TryArrow", "TryArrow", "Momentum Indicators", false, false, false, 1, 0, 2);
inputParameterInfos = new InputParameterInfo[] { new InputParameterInfo("Price", InputParameterInfo.Type.PRICE) };
outputParameterInfos = new OutputParameterInfo[] {
new OutputParameterInfo("Dn", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.ARROW_SYMBOL_DOWN),
new OutputParameterInfo("Up", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.ARROW_SYMBOL_UP)
};
//指标为上下两种箭头
//设置颜色
outputParameterInfos[0].setColor(Color.yellow);
outputParameterInfos[1].setColor(Color.red);
indicatorInfo.setDefaultLevelsInfo(new LevelInfo[] {
new LevelInfo("", 20, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1),
new LevelInfo("", 80, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1),
new LevelInfo("", 40, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1),
new LevelInfo("", 60, OutputParameterInfo.DrawingStyle.DASH_LINE, Color.darkGray, 1, 1)
});
}
public IndicatorResult calculate(int startIndex, int endIndex) {
int startIndexN =startIndex; int endIndexN = endIndex;
return calculate3( startIndexN, endIndexN);
}
public IndicatorResult calculate3(int startIndex, int endIndex) {
if (startIndex - getLookback3() < 0) {
startIndex = getLookback3();
}
if (startIndex > endIndex) {
return new IndicatorResult(0, 0);
}
int maLookback = 0;
int i, j;
console.getOut().format( "si=%d , ei=%d , mb=%d",startIndex,endIndex,maLookback).println();
for (i = startIndex - maLookback, j = 0; i <= endIndex; i++, j++) {
outputs[0][j]=60;
outputs[1][j]=20;
// console.getOut().format( "0 kl=%f ",outputs[0][i]).println();
}
//这里直接赋值给指标数组60, 20
return new IndicatorResult(startIndex, j, endIndex);
}
//各个get/set
public IndicatorInfo getIndicatorInfo() {
return indicatorInfo;
}
public InputParameterInfo getInputParameterInfo(int index) {
if (index < inputParameterInfos.length) {
return inputParameterInfos[index];
}
return null;
}
public OptInputParameterInfo getOptInputParameterInfo(int index) {
if (index < optInputParameterInfos.length) {
return optInputParameterInfos[index];
}
return null;
}
public OutputParameterInfo getOutputParameterInfo(int index) {
if (index < outputParameterInfos.length) {
return outputParameterInfos[index];
}
return null;
}
public void setInputParameter(int index, Object array) {
inputs[index] = (double[][]) array;
}
public void setOptInputParameter(int index, Object value) {
switch (index) {
default:
throw new ArrayIndexOutOfBoundsException(index);
}
}
public void setOutputParameter(int index, Object array) {
outputs[index] = (double[]) array;
}
public int getLookback() {
return getLookback3();
}
public int getLookback2() {
return getLookback3();
}
public int getLookback3() {
return 0;
}
public int getLookforward() {
return 0;
}
}