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.

wrong data from fractal indicator
 Post subject: wrong data from fractal indicator Post rating: 0   New post Posted: Fri 02 Mar, 2012, 17:42 

User rating: 0
Joined: Mon 23 May, 2011, 13:03
Posts: 6
Location: Switzerland,
Dear dukascopy support

I've got some problems with my simple code. I try to get the newest value of fractal indicator of a completely bar. That means from bar #1 the first fix value of fractal indicator. At the picture it would be the value of the bar #4 (5th bar). But I get the value of bar #20 (21rst bar). Have a look at my pic.

here my code and some explications:
data for pic: 5min chart, EURJPY, ASK side, my time is GMT + 1
barCount = barsOnSides for fractal indicator, I tried with 2.
shift = it has to be >= barCount (I think it's because of the lookback function?)

    
private double getFractal(int shift, OfferSide offerSide, int lowOrHigh) throws JFException {
        long time = history.getBar(instrument, selectedPeriod, offerSide, shift).getTime();
        double fractal = 0;

        if (lowOrHigh == 0) {
            double[][] frac = indicators.fractal(this.instrument, this.selectedPeriod, offerSide, this.barCount, Filter.ALL_FLATS, 10 * this.barCount, time, 0);
            Printer.println("frac.length= " + frac.length + "\nfrac[" + lowOrHigh + "].length= " + frac[lowOrHigh].length);
            int i = 0;
            while (Double.isNaN(frac[lowOrHigh][i]) && i < frac[lowOrHigh].length) {
                Printer.println("in while(high), i= " + i);
                i++;
            }
            fractal = frac[lowOrHigh][i];
        }
        if (lowOrHigh == 1) {
            double[][] frac = indicators.fractal(this.instrument, this.selectedPeriod, offerSide, this.barCount, Filter.ALL_FLATS, 10 * this.barCount, time, 0);
            Printer.println("frac.length= " + frac.length + "\nfrac[" + lowOrHigh + "].length= " + frac[lowOrHigh].length);
            int i = 0;
            while (Double.isNaN(frac[lowOrHigh][i]) && i < frac[lowOrHigh].length) {
                Printer.println("in while(low), i= " + i);
                i++;
            }
            fractal = frac[lowOrHigh][i];

        }
        Printer.println("fractal= " + fractal);
        return fractal;
    }


thank you for your help.

best regards,
bigtrader


Attachments:
fractal_on_chart.png [23.62 KiB]
Downloaded 290 times
output_of_fractal.png [7.74 KiB]
Downloaded 286 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: wrong data from fractal indicator Post rating: 0   New post Posted: Mon 05 Mar, 2012, 15:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Have you taken into consideration that in the result array the 0th is the oldest bar and bar with index frac[lowOrHigh].length - 1 is the latest one?
Also please follow through the following checklist:
https://www.dukascopy.com/wiki/#Indicato ... _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