Hi, I've been trying to call some indicators using method but can't seem to get it to work. Any idea?
package jforex;
import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;
public class test implements IStrategy {
public double amount = 0.1;
public int ema_duration = 5;
public int rsi_duration = 9;
public int bar_shift = 1;
public Instrument instrument = Instrument.EURUSD;
public Period period = Period.FIFTEEN_MINS;
public IEngine engine;
public IHistory history;
public IIndicators indicators;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.history = context.getHistory();
this.indicators = context.getIndicators();
}
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 period, IBar ask_bar, IBar bid_bar) throws JFException {
double ema_value = GetEMA(ema_duration, period, bar_shift);
double rsi_value = GetRSI(rsi_duration, period, bar_shift);
}
private double GetEMA(int duration, Period period, int shift) {
return ema_value = indicators.ema(this.instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, duration, shift);
}
private double GetRSI(int duration, Period period, int shift) {
return indicators.rsi(this.instrument, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, duration, shift);
}
}