Hello,
I'm moving from metatrader to jforex, but i have one question.
I would like to know why there is a mismatch between the values in the chart SAR indicator and the JAVA API SAR indicator.
For example, if the SAR properties are Acceleration=0.2, Maximum=0.02 the values from the JAVA API are the same.
But if the SAR properties are smaller, for example, Acceleration=0.02, Maximum=0.003 there is a mismatch in the values
and if the properties values get smaller, the mismatch gets bigger.
I use this code for this test:
package jforex;
import java.util.*;
import com.dukascopy.api.*;
public class PSAR_Test implements IStrategy {
private IConsole console;
private IIndicators indicators;
private static final Filter indFilter = Filter.WEEKENDS;
private static final double SAR_Step=0.02;
private static final double SAR_maximum=0.003;
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
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 askBar, IBar bidBar) throws JFException {
if(instrument==instrument.EURUSD && period == Period.ONE_HOUR) {
double[] sar = indicators.sar(instrument, Period.ONE_HOUR, OfferSide.BID, SAR_Step, SAR_maximum, indFilter, 0, bidBar.getTime(), 1);
String sar_value = String.format("%1$,.5f", sar[0]);
console.getOut().println("pSAR("+new Date(bidBar.getTime())+")> [" + instrument.name()+"/"+period.name()+"] sar_value: " + sar_value);
}
}
}
Thanks in advance.