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.

SAR not returning the Correct value for time frame
 Post subject: SAR not returning the Correct value for time frame Post rating: 0   New post Posted: Fri 08 Oct, 2010, 09:21 

User rating: 0
Joined: Wed 28 Jul, 2010, 11:35
Posts: 3
Please consider the attached code sample. I've been battling with the SAR, specifically the FOUR_HOURS Timeframe. The value it is returning is not what the chart is showing. When I do the ONE_HOUR it returns fine.

What am I missing?

Please help, I've spent a good 4 hours trying to figure this out.
import java.util.*;

import com.dukascopy.api.*;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class SARTestv2 implements IStrategy {
   private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
       
    // these are strategy parameters
    private Instrument myInstrument = Instrument.EURUSD;
    private Period myPeriod = Period.FOUR_HOURS;
   
 
    public void onStart(IContext context) throws JFException {
    // we initialise interfaces in the onStart method
        engine = context.getEngine();
        indicators = context.getIndicators();
        console = context.getConsole();
        history = context.getHistory();

        console.getOut().println("Started");
    }   
       
 
   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 == myPeriod){

          console.getOut().println("HOURSAR:"  +indicators.sar(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, 0.01, 0.1, 0));
          console.getOut().println("FOURHOURSAR:"  +indicators.sar(Instrument.EURUSD, Period.FOUR_HOURS, OfferSide.BID, 0.01, 0.1, 0));

       }    
       
         
    }

}


Attachments:
SARTestv2.java [1.64 KiB]
Downloaded 376 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: SAR not returning the Correct value for time frame Post rating: 0   New post Posted: Fri 07 Jan, 2011, 09:59 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please make sure flats filter is disabled (Tools/Preferences/Chart/Flats filtartion).


 
 Post subject: Re: SAR not returning the Correct value for time frame Post rating: 0   New post Posted: Wed 28 Dec, 2011, 23:08 
User avatar

User rating: 1
Joined: Wed 06 Jul, 2011, 23:12
Posts: 42
Location: Romania, Bucharest
I found the same problem with SAR value shown by the indicator on the chart and calculated from inside a strategy, and I am sure that the problem is not caused by the filter option.


 
 Post subject: Re: SAR not returning the Correct value for time frame Post rating: 0   New post Posted: Thu 29 Dec, 2011, 12:40 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please see in JForex wiki https://www.dukascopy.com/wiki/ Section Strategy API/Indicators/Indicator usage checklist.


 

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