I tried to use the following code to get values of SMA200 and ATR200. But I found the values I got are different with the values shows on the chart (screenshot attached). Did I do something wrong? Appreciate if someone can help.
---------------------
package jforex;
import java.util.*;
import com.dukascopy.api.*;
public class Strategy_Test implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private Instrument instrument = Instrument.EURUSD;
private Period timeFrame = Period.THIRTY_MINS;
private int timePeriod = 200;
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();
double SMA = indicators.sma(this.instrument, this.timeFrame, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, this.timePeriod, 0);
double ATR = indicators.atr(this.instrument, this.timeFrame, OfferSide.BID, this.timePeriod, 0);
console.getOut().println("Instrument= "+this.instrument+", Time Frame= "+timeFrame);
console.getOut().println("SMA"+timePeriod+"= "+SMA+", ATR"+timePeriod+"= "+ATR);
this.context.stop();
}
}