Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Values mismatch between chart SAR and java API sar indicator
 Post subject: Values mismatch between chart SAR and java API sar indicator Post rating: 0   New post Posted: Tue 03 Jul, 2012, 17:14 
User avatar

User rating: 0
Joined: Thu 14 Jun, 2012, 16:58
Posts: 5
Location: Portugal, Lisboa
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.


 
 Post subject: Re: Values mismatch between chart SAR and java API sar indicator Post rating: 0   New post Posted: Wed 04 Jul, 2012, 07:39 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please go through the following checklist:
https://www.dukascopy.com/wiki/#Indicator_usage_checklist
Consider the following approach for indicator value comparison:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Include_in_OHLC


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com