Dukascopy
 
 
Wiki JStore Search Login

RENKO and Indicator Calculations With Shift = 0 vs Shift = 1
 Post subject: RENKO and Indicator Calculations With Shift = 0 vs Shift = 1 Post rating: 0   New post Posted: Thu 13 Sep, 2012, 00:45 

User rating: 0
Joined: Thu 30 Aug, 2012, 11:59
Posts: 11
Location: AustraliaAustralia
Dear Dukas Support,

In the latter half of the following post: viewtopic.php?f=88&t=47923, an issue was raised regarding calculations for indicators with Shift = 0, vs Shift = 1 using Renko Feeds as the Feed Descriptor. It was mentioned that there seems to be significant performance issue when calculating with Shift = 0 as opposed to with Shift = 1. The original post was marked as 'Fixed' however, this isn't the case and I have built a little "Bench-Marking" tool to demonstrate.

In the onBar method call as part of the IRenkoBarFeedListener, the following code was inserted:

        int[]    offsets = new int[]{1,0};
        int       runs = 100, shift;
        long    duration;
        org.joda.time.DateTime start, finish;
        try{
            TRIAL_COUNTER++;
            FeedDescriptor renkoFeedDescriptor = this.feedDescriptor;
           
            //Loop through the 'Shift' values, 1 and 0.
            for(int i = 0; i < offsets.length; i++){
                shift       = offsets[i];
               
                //Conduct the Benchmark.
                start       = DateTime.now();
                for(int j = runs -1; j >=0; j--){
                    context.getIndicators().calculateIndicator(renkoFeedDescriptor,new OfferSide[]{offerSide},
                            "DEMA",new AppliedPrice[]{AppliedPrice.CLOSE},new Object[]{10},shift);
                }
                finish      = DateTime.now();
               
                //Determine the duration and report the result.
                duration    = finish.getMillis() - start.getMillis();
                System.out.println("Trial "+TRIAL_COUNTER + ": Duration With Shift: " + shift + ", is: " + duration + "MS After: " + runs + " Indicator Calculations.");
               
            }
        }
        catch(JFException ex){
            //Handle Quietly.
        }



In this above code, the 10 bar DEMA is calculated 100 times, with the indicator shift = 1 (up to last completed bar) and with shift = 0 (including the current bar). The duration of the net calculation for each 100 x batch is then returned to the screen. This process is then repeated each time a new bar is received by the onBar method.

The results are quite clear in my opinion, for trial 2 and beyond, the calculation for shift = 0 takes 12+ seconds, compared to <5MS for Shift = 1, sample output listed below.

Trial 1: Duration With Shift: 1, is: 12MS After: 100 Indicator Calculations.
Trial 1: Duration With Shift: 0, is: 9MS After: 100 Indicator Calculations.
Trial 2: Duration With Shift: 1, is: 5MS After: 100 Indicator Calculations.
Trial 2: Duration With Shift: 0, is: 12843MS After: 100 Indicator Calculations.
Trial 3: Duration With Shift: 1, is: 5MS After: 100 Indicator Calculations.
Trial 3: Duration With Shift: 0, is: 12783MS After: 100 Indicator Calculations.
Trial 4: Duration With Shift: 1, is: 3MS After: 100 Indicator Calculations.
Trial 4: Duration With Shift: 0, is: 12762MS After: 100 Indicator Calculations.
Trial 5: Duration With Shift: 1, is: 4MS After: 100 Indicator Calculations.
Trial 5: Duration With Shift: 0, is: 12758MS After: 100 Indicator Calculations.
Trial 6: Duration With Shift: 1, is: 4MS After: 100 Indicator Calculations.
Trial 6: Duration With Shift: 0, is: 12796MS After: 100 Indicator Calculations.
Trial 7: Duration With Shift: 1, is: 4MS After: 100 Indicator Calculations.
Trial 7: Duration With Shift: 0, is: 12805MS After: 100 Indicator Calculations.
Trial 8: Duration With Shift: 1, is: 3MS After: 100 Indicator Calculations.
Trial 8: Duration With Shift: 0, is: 12788MS After: 100 Indicator Calculations.
Trial 9: Duration With Shift: 1, is: 3MS After: 100 Indicator Calculations.
Trial 9: Duration With Shift: 0, is: 12777MS After: 100 Indicator Calculations.
Trial 10: Duration With Shift: 1, is: 3MS After: 100 Indicator Calculations.
Trial 10: Duration With Shift: 0, is: 12806MS After: 100 Indicator Calculations.

Can you please confirm whether this error can be replicated, the feed descriptor is for a 5pip Renko Brick Size FYI.

Many Thanks and Regards.

ADP.


 
 Post subject: Re: APICLIENT-307 RENKO and Indicator Calculations With Shift = 0 vs Shift = 1 Post rating: 0   New post Posted: Tue 25 Sep, 2012, 08:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
API 2.7.3


 

Jump to:  

cron
  © 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