Hello,
I'm trying to move from other forex trading API's to jforex API, but i'm always stuck in this problem that I can't figure out so i'm writing this topic so anybody could help me.
Every time i calculate, for example, a sar indicator value for my strategy, this value never match the value from the chart.
For example in the picture below, the calculated value (outputed in the 'Messages' table inside the blue circle) it's 1.27661843....
but in the chart, the value it's 1.22492 (indicated with a yellow arrow, green dots).
In the chart it's also some red dots. That's a custom indicator that outputs the calculated sar. Before the 'test start' bar this indicator is under the green indicator (has the exact same value that the default sar indicator), but when the test starts the custom indicator jumps to the 1.27.
What am i doing wrong?
How can i get the sar value plotted in the chart by the default sar indicator, to use in the strategy?
Thanks in advance.

Code taken from the strategy (complete code in attachment):
public class SARWorking implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private final double SAR_ACCELERATION = 0.001;
private final double SAR_MAXIMUM = 0.003;
Object[] params = new Object[]{SAR_ACCELERATION, SAR_MAXIMUM};
private IChart chart;
private IIndicator sar;
private IIndicator mySar;
private IChartPanel chPanel;
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
this.indicators = context.getIndicators();
this.chart = context.getChart(Instrument.EURUSD);
mySar = indicators.getIndicator("SARTEST");
this.chPanel = this.chart.add(mySar, params, new Color[]{Color.RED},new DrawingStyle[]{DrawingStyle.DOTS}, new int[]{1});
sar = indicators.getIndicator("SAR");
this.chPanel = this.chart.add(sar, params, new Color[]{Color.GREEN},new DrawingStyle[]{DrawingStyle.DOTS}, new int[]{1});
Object[] firstIndicatorValues = indicators.calculateIndicator(Instrument.EURUSD,
Period.DAILY, new OfferSide[] {OfferSide.ASK}, "SAR",
new AppliedPrice[]{AppliedPrice.CLOSE}, params, 0);
console.getOut().println("first indicator value: " + ((Object[])firstIndicatorValues)[0]);
}
Code taken from the custom indicator (Complete code in attachment):
public void onStart(IIndicatorContext context) {
IIndicatorsProvider indicatorsProvider = context.getIndicatorsProvider();
sar = indicatorsProvider.getIndicator("SAR");
this.console = context.getConsole();
indicatorInfo = new IndicatorInfo("SARTEST", "pSAR test", "My indicators",
true, false, true, 1, 2, 1);
inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("Price HL", InputParameterInfo.Type.PRICE)};
optInputParameterInfos = new OptInputParameterInfo[] {new OptInputParameterInfo("Acceleration", OptInputParameterInfo.Type.OTHER,
new DoubleRangeDescription(0.001, 0.001, 1, 0.001, 3)), new OptInputParameterInfo("Maximum", OptInputParameterInfo.Type.OTHER,
new DoubleRangeDescription(0.003, 0.001, 1, 0.001, 3))};
outputParameterInfos = new OutputParameterInfo[] {new OutputParameterInfo("sar", OutputParameterInfo.Type.DOUBLE,
OutputParameterInfo.DrawingStyle.DOTS)};
}
public IndicatorResult calculate(int startIndex, int endIndex) {
//calculating startIndex taking into account lookback value
if (startIndex - getLookback() < 0) {
startIndex -= startIndex - getLookback();
}
sar.setInputParameter(0, inputs[0]);
sar.setOptInputParameter(0, sarParams[0]);
sar.setOptInputParameter(1, sarParams[1]);
sar.setOutputParameter(0, outputs[0]);
sar.calculate(startIndex, endIndex);
return sar.calculate(startIndex, endIndex);
}