Dukascopy
 
 
Wiki JStore Search Login

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

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

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

TrendEnvelopes bug api vs chart
 Post subject: TrendEnvelopes bug api vs chart Post rating: 0   New post Posted: Mon 03 Feb, 2014, 18:59 

User rating: 1
Joined: Thu 02 Jan, 2014, 19:06
Posts: 16
Location: ThailandThailand
Could Dukascopy Support or any volunteer try this simple strategy that prints Trend envelopes from chart and from API
your jForex chart preference Filter must be set to ALL_FLATS

I have detected this bug, where the two diverges, I have cleared my cache but that doesn't fix it, so is anyone able to reproduce it?

public class ST implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    private IChartObjectFactory factory;
    private IChart chart;

    Period period = Period.THIRTY_MINS;
    Instrument instrument = Instrument.EURUSD;
    int supertrendPeriod = 15;
    double supertrendDev = 0.25;
   
    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();
        this.userInterface = context.getUserInterface();
       
        chart = context.getChart(instrument);
       
        if (chart!=null){
            factory = chart.getChartObjectFactory();
            chart.add(indicators.getIndicator("TrendEnvelopes"), new Object[]{supertrendPeriod, supertrendDev});
        }
    }


    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage m) throws JFException {
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
    }
   
   
    int lines=0;
 
    public void onBar(Instrument instrument, Period p, IBar a, IBar b) throws JFException {
        if (p == period){

            double[][] st = indicators.trendEnv(instrument, period, OfferSide.BID, supertrendPeriod, supertrendDev, Filter.ALL_FLATS, 1, b.getTime(), 0);

 
            if (chart!=null){
               if (!Double.isNaN(st[0][0])){
                IShortLineChartObject o2=factory.createShortLine("q"+lines,
                        b.getTime(),
                        st[0][0],
                        b.getTime()+period.getInterval(),
                        st[0][0] );
                o2.setColor(Color.CYAN);
                chart.add(o2);
               }else{
                   IShortLineChartObject o2=factory.createShortLine("q"+lines,
                        b.getTime(),
                        st[1][0],
                        b.getTime()+period.getInterval(),
                        st[1][0] );
                o2.setColor(Color.RED);
                chart.add(o2);
               }
                lines++;
            }

           
        }
    }
   
}


Image
Image

huge divergence ^ the high band is given by the API whereas on Chart the low band is still there
I just tried from another demo account, all cache cleared again


Attachments:
Sans titrest.png [62.47 KiB]
Downloaded 380 times
Sans titrest.png [53.74 KiB]
Downloaded 270 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: TrendEnvelopes bug api vs chart Post rating: 0   New post Posted: Fri 29 Aug, 2014, 14:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
To get equal values indicator must be calculated with the same number of values as on chart. Please see the attached version.


Attachments:
ST_v2.java [2.6 KiB]
Downloaded 101 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.
 

Jump to:  

  © 1998-2024 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