Hi
Need help from support or anybody who can help me. Since the last update I don't see my indicator anymore: "HeikenAshiSW" (in the JForex 1M Chart). I need this indicator. Why doesn't it show anymore or work anymore?
Thanks for any help on this matter.
Best regards
GaBe
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.GeneralPath;
import java.util.List;
import java.util.Map;
import com.dukascopy.api.IBar;
import com.dukascopy.api.ITick;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.indicators.IDrawingIndicator;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.IIndicatorContext;
import com.dukascopy.api.indicators.IIndicatorDrawingSupport;
import com.dukascopy.api.indicators.IMinMax;
import com.dukascopy.api.indicators.IndicatorInfo;
import com.dukascopy.api.indicators.IndicatorResult;
import com.dukascopy.api.indicators.InputParameterInfo;
import com.dukascopy.api.indicators.OptInputParameterInfo;
import com.dukascopy.api.indicators.OutputParameterInfo;
public class HeikenAshiSW implements IIndicator, IMinMax
{
private static final int OPEN = 0;
private static final int CLOSE = 1;
private static final int HIGH = 2;
private static final int LOW = 3;
//private static final int VOLUME = 4;
private IndicatorInfo indicatorInfo;
private InputParameterInfo[] inputParameterInfos;
private OutputParameterInfo[] outputParameterInfos;
private OptInputParameterInfo[] optInputParameterInfos;
private static final Color DIM_BLUE = new Color(51, 153, 255);
private static final Color DIM_RED = new Color(222, 57, 57);
private double[][][] inputs = new double[1][][];
private double[][] outputs = new double[2][];
private IIndicatorContext ctx;
public void onStart(IIndicatorContext context)
{
ctx = context;
indicatorInfo = new IndicatorInfo("HeikenAshiSW", "Heiken Ashi SW", "Custom", false, false, false, 1, 0, 2);
inputParameterInfos = new InputParameterInfo[] {
new InputParameterInfo("Price", InputParameterInfo.Type.PRICE)
};
outputParameterInfos = new OutputParameterInfo[] {
new OutputParameterInfo("HA Bull", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.HISTOGRAM)
{{
setColor(DIM_BLUE);
setShowValueOnChart(false);
}},
new OutputParameterInfo("HA Bear", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.HISTOGRAM)
{{
setColor(DIM_RED);
setShowValueOnChart(false);
}},
};
}
public IndicatorResult calculate(int startIndex, int endIndex)
{
//calculating startIndex taking into account lookback value
if (startIndex - getLookback() < 0)
{
startIndex -= startIndex - getLookback();
}
if (startIndex > endIndex)
{
print(String.format("StartIndex[%d] > EndIndexx[%d]", startIndex, endIndex));
return new IndicatorResult(0, 0);
}
int resIndex = 0;
double haOpen, haClose /*, haHigh, haLow */;
for(int i = startIndex; i <= endIndex; i++, resIndex++)
{
haOpen = (inputs[0][OPEN][i - 1] + inputs[0][CLOSE][i - 1]) / 2;
haClose =(inputs[0][OPEN][i] + inputs[0][HIGH][i] + inputs[0][LOW][i] + inputs[0][CLOSE][i]) / 4;
// haHigh = Math.max(inputs[0][HIGH][i], Math.max(haOpen, haClose));
// haLow = Math.min(inputs[0][LOW][i], Math.min(haOpen, haClose));
if (haOpen < haClose)
{
outputs[0][resIndex] = 0.8;
outputs[1][resIndex] = 0.0;
}
else
{
outputs[0][resIndex] = 0.0;
outputs[1][resIndex] = 0.8;
}
}
return new IndicatorResult(startIndex, resIndex);
}
public IndicatorInfo getIndicatorInfo() {
return indicatorInfo;
}
public InputParameterInfo getInputParameterInfo(int index) {
if (index <= inputParameterInfos.length) {
return inputParameterInfos[index];
}
return null;
}
public int getLookback() {
return 1;
}
public int getLookforward() {
return 0;
}
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 OptInputParameterInfo getOptInputParameterInfo(int index) {
if (index <= optInputParameterInfos.length) {
return optInputParameterInfos[index];
}
return null;
}
public void setOptInputParameter(int index, Object value) {
}
public void setOutputParameter(int index, Object array) {
outputs[index] = (double[]) array;
}
private void print(String txt)
{
ctx.getConsole().getOut().println(txt);
}
@Override
public double[] getMinMax(int outputIdx, Object values,
int firstVisibleValueIndex, int lastVisibleValueIndex)
{
// TODO Auto-generated method stub
return new double[] { 1.0, 1.0 };
}
}