hi,
I'm trying to run a simple Strategy using the alligator indicator in the historical tester. For some reason the values I get are not identical to the chart's alligator indicator.
I'm using for the Alligator the following params: Jaw:13, Teeth:8, Lips:5
Historical Tester values:
Bid Side
4ticks at OHLC
1Min Bars
EURUSD
date range 2014.01.30 - 2014.01.31
Here is my code:
package jforex;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import com.dukascopy.api.Configurable;
import com.dukascopy.api.Filter;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IIndicators.AppliedPrice;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IOrder;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
public class AlligatorStrategy implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IIndicators indicators;
private int counter =0;
private double [] alligator;
private IOrder order = null;
@Configurable("Instrument")
public Instrument selectedInstrument = Instrument.EURUSD;
@Configurable("Period")
public Period selectedPeriod = Period.ONE_MIN;
public Filter indicatorFilter = Filter.NO_FILTER;
private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.indicators = context.getIndicators();
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
for (IOrder order : engine.getOrders()) {
engine.getOrder(order.getLabel()).close();
}
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
if (!instrument.equals(selectedInstrument)) {
return;
}
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (!instrument.equals(selectedInstrument) || !Period.ONE_MIN.equals(period)) {
return;
}
alligator = indicators.alligator(instrument, Period.ONE_MIN, OfferSide.BID, AppliedPrice.CLOSE , 13, 8, 5, 1);
print("Period:%s, Time:%s, alligator[%f,%f,%f]",period,sdf.format(bidBar.getTime()),alligator[0],alligator[1],alligator[2]);
}
private void print (String format, Object...args){
print(String.format(format, args));
}
public void print(String message) {
console.getOut().println(message);
}
}
Please note the below screen shot - you can see that the numbers are not accurate. Can you please advice how to fix that.