I was surprised not to have a matching between the 2 same stochastic indicators, with different shifts
example below printing time+","+ stochshift0[0]+","+stochshift1[0], I expected to see matching one bar period later, but 61 != 59 and 38 != 36
21:29:50 2013-08-21 09:30:00, 76.77527151211142, 61.457811194651185
21:29:50 2013-08-21 09:15:00, 59.70342522974027, 38.30409356724653
21:29:50 2013-08-21 09:00:00, 36.84210526314978, 33.78995433789461
thanks for explanations
full strategy
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class Stoch implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
Period period = Period.FIFTEEN_MINS;
Instrument instrument1 = Instrument.EURCHF;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
df.setTimeZone(TimeZone.getTimeZone("GMT"));
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period p, IBar askBar, IBar bidBar) throws JFException {
if (instrument==instrument1 && p == period ){
double[] stoch0 = indicators.stoch(instrument1, period, OfferSide.BID, 5, 3, IIndicators.MaType.SMA, 3, IIndicators.MaType.SMA, 0);
double[] stoch1 = indicators.stoch(instrument1, period, OfferSide.BID, 5, 3, IIndicators.MaType.SMA, 3, IIndicators.MaType.SMA, 1);
console.getOut().println(df.format(askBar.getTime())+","+stoch0[0]+","+stoch1[0]);
}
}
}