Dukascopy
 
 
Wiki JStore Search Login

Indicator calls very slow on recent data
 Post subject: Indicator calls very slow on recent data Post rating: 0   New post Posted: Fri 14 Oct, 2011, 19:22 

User rating: 0
Joined: Wed 18 May, 2011, 23:26
Posts: 40
Location: Switzerland,
The following code completes at sub-millisecond speeds on september data, but for recent data (september 29 ~19:00) the call to "indicators" interface is taking significantly longer.

long s = System.nanoTime();
double[] result = indicators.sma(instrument, Period.ONE_HOUR, Offerside.BID, AppliedPrice.CLOSE, 200, Filter.WEEKENDS, 1, tick.getTime(), 0);
long e = System.nanoTime();
System.out.println((e-s)/1000000 + "ms");


Before September 29 ~19:00 sub-millisecond execution speeds.
After September 29 ~19:00 - ~300ms execution speeds

Cache has been cleared, still no luck.

Please advice as to what other information is needed and possible fixes.


 
 Post subject: Re: Indicator calls very slow on recent data Post rating: 0   New post Posted: Fri 14 Oct, 2011, 20:38 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
I can confirm that this is a bug and happens on my setup too.

linux, java6

regards,
mm


 
 Post subject: Re: Indicator calls very slow on recent data Post rating: 0   New post Posted: Fri 14 Oct, 2011, 20:45 

User rating: 0
Joined: Wed 18 May, 2011, 23:26
Posts: 40
Location: Switzerland,
Here's a test strategy and its output:

package jforex;

import java.util.*;

import com.dukascopy.api.*;
import java.text.SimpleDateFormat;

public class IndicatorTest implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;
   private IUserInterface userInterface;
   
   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();
   }

   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 {
                SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
                long threshold = 50;
                long s = System.nanoTime();
                double[] result = indicators.sma(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 50, Filter.WEEKENDS, 1, tick.getTime(), 0);
                long e = System.nanoTime();
                if ((e - s) / 1000000 > threshold) {
                    console.getErr().println("Indicator execution time > " + threshold + "ms @" + sdf.format(tick.getTime()) + " -> " + (e - s) / 1000000 + "ms");
                }
   }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}


Quote:
Indicator execution time > 50ms @11-09-30 17:00:04 -> 289ms
Indicator execution time > 50ms @11-10-02 17:00:20 -> 295ms
Indicator execution time > 50ms @11-10-02 17:00:20 -> 292ms
Indicator execution time > 50ms @11-10-02 17:00:24 -> 292ms
Indicator execution time > 50ms @11-10-02 17:01:28 -> 297ms
Indicator execution time > 50ms @11-10-02 17:01:29 -> 290ms
Indicator execution time > 50ms @11-10-02 17:01:29 -> 293ms
Indicator execution time > 50ms @11-10-02 17:01:29 -> 291ms
Indicator execution time > 50ms @11-10-02 17:01:33 -> 291ms
...


 
 Post subject: Re: Indicator calls very slow on recent data Post rating: 0   New post Posted: Mon 17 Oct, 2011, 08:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We didn't manage to reproduce the behavior. Starting from the second tick, indicator calls completed within ~15ms and normally they were from 0 to 3 ms. In our tests we used a modified version of you strategy:
package jforex.strategies.indicators;

import com.dukascopy.api.*;

import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class IndicatorTest implements IStrategy {
   private IConsole console;
   private IIndicators indicators;

   @SuppressWarnings("serial")
   SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss"){{
      setTimeZone(TimeZone.getTimeZone("GMT"));
   }};
   
   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 {

      if(instrument != Instrument.EURUSD){
         return;
      }
      
      long [] timeArr = new long [] {tick.getTime(),
            tick.getTime() - 2 * Period.DAILY.getInterval(),
            tick.getTime() - 3 * Period.DAILY.getInterval(),
            tick.getTime() - 7 * Period.DAILY.getInterval()};
      
      Period[] periodArr = new Period[] { Period.ONE_HOUR, Period.TEN_MINS, Period.TEN_SECS, Period.DAILY};
      
      for(Period period : periodArr){
         for(long time : timeArr){
            callSma(time, period);
         }
      }
   }
   
   private void callSma(long time, Period period) throws JFException{
      long threshold = 50;
      long start = System.currentTimeMillis();
      double[] result = indicators.sma(Instrument.EURUSD, period, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 50,
            Filter.WEEKENDS, 1, time, 0);
      long end = System.currentTimeMillis();
      if (end - start > threshold) {
         console.getErr().println(
               period + " onTick Indicator execution time > " + threshold + "ms @" + sdf.format(time) + " -> " + (end - start) + "ms");
      } else {
         console.getOut().println(period + " onTick Indicator execution time @" + sdf.format(time) + " -> " + (end - start) + "ms");
      }   
   }

   public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
   }
}


 
 Post subject: Re: Indicator calls very slow on recent data Post rating: 0   New post Posted: Tue 02 Oct, 2012, 21:42 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
I still encounter this bug when trying to backtest. I am now ready to start gathering data for my strategy, but still run into the problem of this slow down.

import com.dukascopy.api.*;
import java.text.SimpleDateFormat;

import com.packages.globalincludes.Helper;
import org.javasimon.SimonManager;
import org.javasimon.Split;

public class TestStrategy implements IStrategy {
   
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    private Helper helper;
   
    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();
       
        helper = new Helper();
    }

    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 {
       
        SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
        long threshold = 50;
        long s = System.nanoTime();
        Split split = SimonManager.getStopwatch("sma").start();
        double[] result = indicators.sma(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 50, Filter.ALL_FLATS, 1, tick.getTime(), 0);
        split.stop();
        split = SimonManager.getStopwatch("rsi").start();
        double[] rsi = indicators.rsi(instrument, Period.ONE_MIN, OfferSide.BID, IIndicators.AppliedPrice.HIGH, 7, Filter.ALL_FLATS, 30, tick.getTime(), 0);
        split.stop();
        split = SimonManager.getStopwatch("macd").start();
        double[][] macd = indicators.macd(instrument, Period.FIVE_MINS, OfferSide.BID, IIndicators.AppliedPrice.HIGH, 3, 9, 3, Filter.ALL_FLATS, 30, tick.getTime(), 0);
        split.stop();
        split = SimonManager.getStopwatch("sto").start();
        double[][] sto = indicators.stoch(instrument, Period.FIVE_MINS, OfferSide.BID, 10, 3, IIndicators.MaType.SMA, 3, IIndicators.MaType.SMA, Filter.ALL_FLATS, 30, tick.getTime(), 0);
        split.stop();
        split = SimonManager.getStopwatch("mfi").start();
        double[] mfi = indicators.mfi(instrument, Period.TEN_MINS, OfferSide.BID, 7, Filter.ALL_FLATS, 30, tick.getTime(), 0);
        split.stop();
        long e = System.nanoTime();
        if ((e - s) / 1000000 > threshold) {
            console.getErr().println("Indicator execution time > " + threshold + "ms @" + sdf.format(tick.getTime()) + " -> " + (e - s) / 1000000 + "ms");
            console.getErr().println("SMA : " + SimonManager.getStopwatch("sma"));
            console.getErr().println("RSI : " + SimonManager.getStopwatch("rsi"));
            console.getErr().println("MACD : " + SimonManager.getStopwatch("macd"));
            console.getErr().println("STO : " + SimonManager.getStopwatch("sto"));
            console.getErr().println("MFI : " + SimonManager.getStopwatch("mfi"));
        }
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       
        if(period.equals(Period.FIVE_MINS))
            console.getOut().println(helper.convertTimeFormat(context.getHistory().getTimeOfLastTick(instrument)));
    }
}


The output when it slows down is this:
Quote:
SMA : Simon Stopwatch: total 1.07 s, counter 121606, max 199 ms, min 4.75 us, mean 8.78 us [sma INHERIT]

RSI : Simon Stopwatch: total 1.74 s, counter 121606, max 20.5 ms, min 9.50 us, mean 14.3 us [rsi INHERIT]

MACD : Simon Stopwatch: total 15.2 s, counter 121606, max 452 ms, min 10.3 us, mean 125 us [macd INHERIT]

STO : Simon Stopwatch: total 45.1 s, counter 121606, max 494 ms, min 87.1 us, mean 371 us [sto INHERIT]

MFI : Simon Stopwatch: total 2.66 s, counter 121606, max 11.5 ms, min 15.4 us, mean 21.9 us [mfi INHERIT]


My code for where I load specify the starting backtest date in StandaloneJForexBacktest:
//subscribe to the instruments
        Set<Instrument> instruments = new HashSet<Instrument>();
        instruments.add(Instrument.EURUSD);
        m_LOGGER.info("Subscribing instruments...");
        client.setSubscribedInstruments(instruments);
       
        Calendar start = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        start.set(2012, 05, 01, 00, 00, 00);
        //Calendar end = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        //end.set(2011, 10, 10, 00, 00, 00);
        Date dateTo = new Date();
        client.setDataInterval(ITesterClient.DataLoadingMethod.ALL_TICKS, start.getTimeInMillis(), dateTo.getTime());


The last tick report in onBar before this happens is
Quote:
01.06.2012 20:59:59
just before the weekend bars come in.
Please note that the start set date is June 1st (months start from 00).


 
 Post subject: Re: Indicator calls very slow on recent data Post rating: 0   New post Posted: Fri 05 Oct, 2012, 08:54 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We could not replicate this by running the following program:
package singlejartest;

import com.dukascopy.api.*;
import com.dukascopy.api.system.ISystemListener;
import com.dukascopy.api.system.ITesterClient;
import com.dukascopy.api.system.ITesterClient.DataLoadingMethod;
import com.dukascopy.api.system.TesterFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.Future;

/**
 * This small program demonstrates how to initialize Dukascopy tester and start a strategy
 */
@RequiresFullAccess
public class HistoryIntervalIndFromToPerformance {
   private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);

   // url of the DEMO jnlp
   //private static String jnlpUrl = "https://www.dukascopy.com/client/demo/jclient/jforex.jnlp";
    private static String jnlpUrl = "https://www.dukascopy.com/client/demo/jclient/jforex.jnlp";
    private static String userName = "";
    private static String password = "";
   

   public static void main(String[] args) throws Exception {
      // get the instance of the IClient interface
      final ITesterClient client = TesterFactory.getDefaultInstance();
      // set the listener that will receive system events
      client.setSystemListener(new ISystemListener() {
         @Override
         public void onStart(long processId) {
            LOGGER.info("Strategy started: " + processId);
         }

         @Override
         public void onStop(long processId) {
            if (client.getStartedStrategies().size() == 0) {
               System.exit(0);
            }
         }

         @Override
         public void onConnect() {
            LOGGER.info("Connected");
         }

         @Override
         public void onDisconnect() {
            // tester doesn't disconnect
         }
      });

      LOGGER.info("Connecting...");
      // connect to the server using jnlp, user name and password
      // connection is needed for data downloading
      client.connect(jnlpUrl, userName, password);

      // wait for it to connect
      int i = 10; // wait max ten seconds
      while (i > 0 && !client.isConnected()) {
         Thread.sleep(1000);
         i--;
      }
      if (!client.isConnected()) {
         LOGGER.error("Failed to connect Dukascopy servers");
         System.exit(1);
      }

      final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));

      Date dateFrom = dateFormat.parse("05/01/2012 00:00:00");
      Date dateTo = dateFormat.parse("05/01/2012 00:01:00");

      client.setDataInterval(DataLoadingMethod.ALL_TICKS, dateFrom.getTime(), dateTo.getTime());

      // set instruments that will be used in testing
      Set<Instrument> instruments = new HashSet<Instrument>();
      instruments.add(Instrument.EURUSD);
      LOGGER.info("Subscribing instruments...");
      client.setSubscribedInstruments(instruments);
      client.setInitialDeposit(Instrument.EURUSD.getSecondaryCurrency(), 50000);
      
      // load data
      LOGGER.info("Downloading data");
      Future<?> future = client.downloadData(null);
      // wait for downloading to complete
      future.get();
      // start the strategy
      LOGGER.info("Starting strategy"); 

      client.startStrategy(new IStrategy(){

          private Instrument instrument = Instrument.EURUSD;

          private IConsole console;
          private IIndicators indicators;
         
          private double maxTolerance = 0.1;

          @Override
          public void onStart(IContext context) throws JFException {

              console = context.getConsole();
              indicators = context.getIndicators();
          }
         
          private void printIndies(ITick tick) throws JFException{
             
              long start = System.nanoTime();
              print("print indicator results for tick=" + tick);
              print((System.nanoTime() - start), " sma=", indicators.sma(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 50, Filter.ALL_FLATS, 1, tick.getTime(), 0));       
              start = System.nanoTime();
             
              print((System.nanoTime() - start), " rsi=", indicators.rsi(instrument, Period.ONE_MIN, OfferSide.BID, IIndicators.AppliedPrice.HIGH, 7, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
              start = System.nanoTime();
             
              print((System.nanoTime() - start), " macd=", indicators.macd(instrument, Period.FIVE_MINS, OfferSide.BID, IIndicators.AppliedPrice.HIGH, 3, 9, 3, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
              start = System.nanoTime();
             
              print((System.nanoTime() - start), " stoch=", indicators.stoch(instrument, Period.FIVE_MINS, OfferSide.BID, 10, 3, IIndicators.MaType.SMA, 3, IIndicators.MaType.SMA, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
              start = System.nanoTime();
             
              print((System.nanoTime() - start), " mfi=", indicators.mfi(instrument, Period.TEN_MINS, OfferSide.BID, 7, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
              start = System.nanoTime();

          }
         
          private void print(Object o) {
              console.getOut().println(o);
          }
         
          private void print(long duration, String comment, Object result) {
             String resultStr = result instanceof double[] ? arrayToString((double[])result) :
                result instanceof double[][] ? arrayToString((double[][])result) :
                result.toString();
             double durationSecs = duration / Math.pow(10, 9);
              String str = String.format("duration = %.9f secs %s %s", durationSecs, comment, resultStr);
              if(durationSecs < maxTolerance){
                  print(str);
              } else {
                  console.getErr().println(str);
              }
          }
         
         private String arrayToString(double[] arr) {
            StringBuffer sb = new StringBuffer();
            for (int r = 0; r < arr.length; r++) {
               sb.append(String.format("[%s] %.5f; ", r, arr[r]));
            }
            return sb.toString();
         }
         
         private String arrayToString(double[][] arr) {
            StringBuffer sb = new StringBuffer();
            for (int r = 0; r < arr.length; r++) {
               for (int c = 0; c < arr[r].length; c++) {
                  sb.append(String.format("[%s][%s] %.5f; ", r, c, arr[r][c]));
               }
               sb.append("; ");
            }
            return sb.toString();
         }

          @Override
          public void onTick(Instrument instrument, ITick tick) throws JFException {
             if(instrument == this.instrument){
                printIndies(tick);
             }
             
          }

          @Override
          public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}

          @Override
          public void onMessage(IMessage message) throws JFException {}

          @Override
          public void onAccount(IAccount account) throws JFException {}

          @Override
          public void onStop() throws JFException {}


         
      });
      // now it's running

   }
}

Please provide a more precise case. Also for more efficient assistance please provide full example programs and please don't use any external libraries in them.


Attachments:
HistoryIntervalIndFromToPerformance.java [8.37 KiB]
Downloaded 352 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: Indicator calls very slow on recent data Post rating: 0   New post Posted: Tue 09 Oct, 2012, 03:23 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
Many thanks for the test code and I do not have any problems running your version of it. I think this is because it only runs the test for one minute and doesn't overlap with the weekend ticks in question.
As mentioned in my post my date format has months starting from 00, meaning that the month in question is June. The problem arises when going from 20:55 on June 1st, 2012 and 21:00 on June 3rd, 2012. In this range of time it would seem that the first indicator calculation called from within onTick slows down significantly and so does the whole calling process.

To replicate this I have change your example code to the following.
new printIndies:
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
        long threshold = 50;
        long s = System.nanoTime();
       
        long start = System.nanoTime();
        print("print indicator results for tick=" + tick);
        print((System.nanoTime() - start), " sma=", indicators.sma(m_instrument, Period.ONE_HOUR, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 50, Filter.ALL_FLATS, 1, tick.getTime(), 0));       
        start = System.nanoTime();

        print((System.nanoTime() - start), " rsi=", indicators.rsi(m_instrument, Period.ONE_MIN, OfferSide.BID, IIndicators.AppliedPrice.HIGH, 7, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
        start = System.nanoTime();

        print((System.nanoTime() - start), " macd=", indicators.macd(m_instrument, Period.FIVE_MINS, OfferSide.BID, IIndicators.AppliedPrice.HIGH, 3, 9, 3, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
        start = System.nanoTime();

        print((System.nanoTime() - start), " stoch=", indicators.stoch(m_instrument, Period.FIVE_MINS, OfferSide.BID, 10, 3, IIndicators.MaType.SMA, 3, IIndicators.MaType.SMA, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
        start = System.nanoTime();

        print((System.nanoTime() - start), " mfi=", indicators.mfi(m_instrument, Period.TEN_MINS, OfferSide.BID, 7, Filter.ALL_FLATS, 30, tick.getTime(), 0));       
        start = System.nanoTime();
       
        long e = System.nanoTime();
        if ((e - s) / Math.pow(10, 6) > threshold) {
            console.getErr().println("Indicator execution time > " + threshold + "ms @" + sdf.format(tick.getTime()) + " -> " + (e - s) / Math.pow(10, 6) + "ms");
        }


new print:
private void print(long duration, String comment, Object result) {
        String resultStr = result instanceof double[] ? arrayToString((double[])result) :
                result instanceof double[][] ? arrayToString((double[][])result) :
                result.toString();
        double durationSecs = duration / Math.pow(10, 6);
        String str = String.format("duration = %.9f ms %s %s", durationSecs, comment, resultStr);
        console.getErr().println(str);
    }


Example print outs before time in question is hit:
Quote:
duration = 0.067888000 secs sma= [0] 1.23724;

duration = 0.001327000 secs rsi= [0] 43.37644; [1] 49.40220; [2] 41.14940; [3] 38.97889; [4] 52.96791; [5] 51.08341; [6] 63.56142; [7] 68.15622; [8] 72.46081; [9] 74.14011; [10] 72.66315; [11] 70.21528; [12] 68.42249; [13] 73.54482; [14] 89.77297; [15] 90.34358; [16] 92.98273; [17] 82.37536; [18] 80.83837; [19] 63.72885; [20] 67.42461; [21] 70.32928; [22] 62.85629; [23] 59.18764; [24] 54.54496; [25] 56.53383; [26] 45.40776; [27] 56.61446; [28] 54.21020; [29] 53.15674;

duration = 0.001327000 secs macd= [0][0] 0.00029; [0][1] 0.00018; [0][2] 0.00013; [0][3] 0.00031; [0][4] 0.00034; [0][5] 0.00082; [0][6] 0.00153; [0][7] 0.00158; [0][8] 0.00128; [0][9] 0.00139; [0][10] 0.00125; [0][11] 0.00093; [0][12] 0.00060; [0][13] 0.00023; [0][14] -0.00042; [0][15] -0.00059; [0][16] -0.00037; [0][17] -0.00053; [0][18] -0.00059; [0][19] -0.00040; [0][20] -0.00018; [0][21] -0.00012; [0][22] -0.00034; [0][23] -0.00044; [0][24] -0.00025; [0][25] -0.00011; [0][26] 0.00047; [0][27] 0.00057; [0][28] 0.00047; [0][29] 0.00036; ; [1][0] 0.00023; [1][1] 0.00021; [1][2] 0.00017; [1][3] 0.00024; [1][4] 0.00029; [1][5] 0.00056; [1][6] 0.00105; [1][7] 0.00131; [1][8] 0.00129; [1][9] 0.00134; [1][10] 0.00129; [1][11] 0.00111; [1][12] 0.00086; [1][13] 0.00054; [1][14] 0.00006; [1][15] -0.00027; [1][16] -0.00032; [1][17] -0.00042; [1][18] -0.00051; [1][19] -0.00045; [1][20] -0.00032; [1][21] -0.00022; [1][22] -0.00028; [1][23] -0.00036; [1][24] -0.00030; [1][25] -0.00020; [1][26] 0.00013; [1][27] 0.00035; [1][28] 0.00041; [1][29] 0.00039; ; [2][0] 0.00006; [2][1] -0.00002; [2][2] -0.00004; [2][3] 0.00007; [2][4] 0.00005; [2][5] 0.00027; [2][6] 0.00049; [2][7] 0.00027; [2][8] -0.00002; [2][9] 0.00005; [2][10] -0.00005; [2][11] -0.00018; [2][12] -0.00025; [2][13] -0.00031; [2][14] -0.00048; [2][15] -0.00033; [2][16] -0.00005; [2][17] -0.00011; [2][18] -0.00008; [2][19] 0.00005; [2][20] 0.00014; [2][21] 0.00010; [2][22] -0.00006; [2][23] -0.00008; [2][24] 0.00006; [2][25] 0.00010; [2][26] 0.00034; [2][27] 0.00022; [2][28] 0.00006; [2][29] -0.00002; ;

duration = 0.001327000 secs stoch= [0][0] 80.63485; [0][1] 72.63467; [0][2] 66.10487; [0][3] 75.43976; [0][4] 79.14514; [0][5] 89.25750; [0][6] 89.51867; [0][7] 84.51394; [0][8] 78.74741; [0][9] 80.90961; [0][10] 84.92358; [0][11] 83.61338; [0][12] 75.66238; [0][13] 56.49977; [0][14] 36.48364; [0][15] 22.35144; [0][16] 21.37736; [0][17] 19.64573; [0][18] 17.34439; [0][19] 20.12748; [0][20] 29.66357; [0][21] 28.06905; [0][22] 24.11288; [0][23] 18.72041; [0][24] 36.10962; [0][25] 55.03546; [0][26] 73.73592; [0][27] 77.74093; [0][28] 80.49020; [0][29] 79.01961; ; [1][0] 72.08640; [1][1] 76.60719; [1][2] 73.12480; [1][3] 71.39310; [1][4] 73.56326; [1][5] 81.28080; [1][6] 85.97377; [1][7] 87.76337; [1][8] 84.26001; [1][9] 81.39032; [1][10] 81.52687; [1][11] 83.14886; [1][12] 81.39978; [1][13] 71.92518; [1][14] 56.21526; [1][15] 38.44495; [1][16] 26.73748; [1][17] 21.12485; [1][18] 19.45583; [1][19] 19.03920; [1][20] 22.37848; [1][21] 25.95337; [1][22] 27.28183; [1][23] 23.63411; [1][24] 26.31431; [1][25] 36.62183; [1][26] 54.96033; [1][27] 68.83744; [1][28] 77.32235; [1][29] 79.08358; ;

duration = 0.001397000 secs mfi= [0] 25.46583; [1] 38.83671; [2] 52.42709; [3] 67.50396; [4] 83.18643; [5] 85.79173; [6] 72.37591; [7] 59.20416; [8] 45.69092; [9] 31.11097; [10] 27.08504; [11] 25.67123; [12] 27.05753; [13] 28.06649; [14] 42.27905; [15] 55.73390; [16] 71.29635; [17] 71.42412; [18] 73.05110; [19] 86.82438; [20] 100.00000; [21] 86.24082; [22] 72.85128; [23] 73.67995; [24] 61.30206; [25] 44.67427; [26] 29.29980; [27] 26.09554; [28] 37.49803; [29] 47.42964;


Between the times in question:
Quote:
Indicator execution time > 50ms @12-06-03 17:00:38 -> 358.326902ms

duration = 0.522013000 secs sma= [0] 1.23734;

duration = 0.001118000 secs rsi= [0] 38.74599; [1] 51.02194; [2] 52.60501; [3] 46.47159; [4] 45.58576; [5] 55.48532; [6] 55.48532; [7] 41.97346; [8] 59.62218; [9] 65.70654; [10] 66.29900; [11] 78.99817; [12] 82.57336; [13] 87.26902; [14] 89.22348; [15] 85.15627; [16] 86.42012; [17] 68.83694; [18] 75.08070; [19] 78.51664; [20] 68.36517; [21] 73.93497; [22] 72.19043; [23] 59.83648; [24] 56.10280; [25] 75.62315; [26] 81.92981; [27] 71.43972; [28] 65.96543; [29] 25.81261;

duration = 0.001118000 secs macd= [0][0] 0.00139; [0][1] 0.00125; [0][2] 0.00093; [0][3] 0.00060; [0][4] 0.00023; [0][5] -0.00042; [0][6] -0.00059; [0][7] -0.00037; [0][8] -0.00053; [0][9] -0.00059; [0][10] -0.00040; [0][11] -0.00018; [0][12] -0.00012; [0][13] -0.00034; [0][14] -0.00044; [0][15] -0.00025; [0][16] -0.00011; [0][17] 0.00047; [0][18] 0.00057; [0][19] 0.00047; [0][20] 0.00036; [0][21] -0.00005; [0][22] -0.00033; [0][23] -0.00034; [0][24] -0.00031; [0][25] -0.00008; [0][26] 0.00015; [0][27] 0.00029; [0][28] 0.00044; [0][29] -0.00007; ; [1][0] 0.00134; [1][1] 0.00129; [1][2] 0.00111; [1][3] 0.00086; [1][4] 0.00054; [1][5] 0.00006; [1][6] -0.00027; [1][7] -0.00032; [1][8] -0.00042; [1][9] -0.00051; [1][10] -0.00045; [1][11] -0.00032; [1][12] -0.00022; [1][13] -0.00028; [1][14] -0.00036; [1][15] -0.00030; [1][16] -0.00020; [1][17] 0.00013; [1][18] 0.00035; [1][19] 0.00041; [1][20] 0.00039; [1][21] 0.00017; [1][22] -0.00008; [1][23] -0.00021; [1][24] -0.00026; [1][25] -0.00017; [1][26] -0.00001; [1][27] 0.00014; [1][28] 0.00029; [1][29] 0.00011; ; [2][0] 0.00005; [2][1] -0.00005; [2][2] -0.00018; [2][3] -0.00025; [2][4] -0.00031; [2][5] -0.00048; [2][6] -0.00033; [2][7] -0.00005; [2][8] -0.00011; [2][9] -0.00008; [2][10] 0.00005; [2][11] 0.00014; [2][12] 0.00010; [2][13] -0.00006; [2][14] -0.00008; [2][15] 0.00006; [2][16] 0.00010; [2][17] 0.00034; [2][18] 0.00022; [2][19] 0.00006; [2][20] -0.00002; [2][21] -0.00022; [2][22] -0.00025; [2][23] -0.00013; [2][24] -0.00005; [2][25] 0.00009; [2][26] 0.00016; [2][27] 0.00015; [2][28] 0.00015; [2][29] -0.00018; ;

print indicator results for tick=1338757239126[2012-06-03 21:00:39.126+0000] / 1.24194 / 1.24162

duration = 0.001327000 secs stoch= [0][0] 80.90961; [0][1] 84.92358; [0][2] 83.61338; [0][3] 75.66238; [0][4] 56.49977; [0][5] 36.48364; [0][6] 22.35144; [0][7] 21.37736; [0][8] 19.64573; [0][9] 17.34439; [0][10] 20.12748; [0][11] 29.66357; [0][12] 28.06905; [0][13] 24.11288; [0][14] 18.72041; [0][15] 36.10962; [0][16] 55.03546; [0][17] 73.73592; [0][18] 77.74093; [0][19] 80.49020; [0][20] 68.92157; [0][21] 53.72549; [0][22] 37.38358; [0][23] 31.56604; [0][24] 29.08976; [0][25] 33.91063; [0][26] 41.09866; [0][27] 56.57945; [0][28] 74.57108; [0][29] 63.77286; ; [1][0] 81.39032; [1][1] 81.52687; [1][2] 83.14886; [1][3] 81.39978; [1][4] 71.92518; [1][5] 56.21526; [1][6] 38.44495; [1][7] 26.73748; [1][8] 21.12485; [1][9] 19.45583; [1][10] 19.03920; [1][11] 22.37848; [1][12] 25.95337; [1][13] 27.28183; [1][14] 23.63411; [1][15] 26.31431; [1][16] 36.62183; [1][17] 54.96033; [1][18] 68.83744; [1][19] 77.32235; [1][20] 75.71756; [1][21] 67.71242; [1][22] 53.34355; [1][23] 40.89170; [1][24] 32.67979; [1][25] 31.52214; [1][26] 34.69968; [1][27] 43.86291; [1][28] 57.41640; [1][29] 64.97446; ;

duration = 0.001048000 secs mfi= [0] 85.79173; [1] 72.37591; [2] 59.20416; [3] 45.69092; [4] 31.11097; [5] 27.08504; [6] 25.67123; [7] 27.05753; [8] 28.06649; [9] 42.27905; [10] 55.73390; [11] 71.29635; [12] 71.42412; [13] 73.05110; [14] 86.82438; [15] 100.00000; [16] 86.24082; [17] 72.85128; [18] 73.67995; [19] 61.30206; [20] 44.67427; [21] 29.29980; [22] 26.09554; [23] 37.49803; [24] 40.42155; [25] 26.77303; [26] 37.78363; [27] 54.41968; [28] 75.14544; [29] 68.29651;

Indicator execution time > 50ms @12-06-03 17:00:38 -> 296.564705ms


when I comment out the sma and then the rsi is first to be calculated:
Quote:
Indicator execution time > 50ms @12-06-03 17:02:38 -> 248.192428ms


duration = 2.717620000 ms rsi= [0] 52.60500; [1] 46.47159; [2] 45.58575; [3] 55.48531; [4] 55.48531; [5] 41.97346; [6] 59.62218; [7] 65.70653; [8] 66.29900; [9] 78.99817; [10] 82.57336; [11] 87.26902; [12] 89.22348; [13] 85.15627; [14] 86.42012; [15] 68.83694; [16] 75.08070; [17] 78.51664; [18] 68.36517; [19] 73.93497; [20] 72.19043; [21] 59.83648; [22] 56.10280; [23] 75.62315; [24] 81.92981; [25] 71.43972; [26] 65.96543; [27] 25.81261; [28] 26.70997; [29] 27.72982;

duration = 0.001118000 ms macd= [0][0] 0.00139; [0][1] 0.00125; [0][2] 0.00093; [0][3] 0.00060; [0][4] 0.00023; [0][5] -0.00042; [0][6] -0.00059; [0][7] -0.00037; [0][8] -0.00053; [0][9] -0.00059; [0][10] -0.00040; [0][11] -0.00018; [0][12] -0.00012; [0][13] -0.00034; [0][14] -0.00044; [0][15] -0.00025; [0][16] -0.00011; [0][17] 0.00047; [0][18] 0.00057; [0][19] 0.00047; [0][20] 0.00036; [0][21] -0.00005; [0][22] -0.00033; [0][23] -0.00034; [0][24] -0.00031; [0][25] -0.00008; [0][26] 0.00015; [0][27] 0.00029; [0][28] 0.00044; [0][29] -0.00005; ; [1][0] 0.00134; [1][1] 0.00129; [1][2] 0.00111; [1][3] 0.00086; [1][4] 0.00054; [1][5] 0.00006; [1][6] -0.00027; [1][7] -0.00032; [1][8] -0.00042; [1][9] -0.00051; [1][10] -0.00045; [1][11] -0.00032; [1][12] -0.00022; [1][13] -0.00028; [1][14] -0.00036; [1][15] -0.00030; [1][16] -0.00020; [1][17] 0.00013; [1][18] 0.00035; [1][19] 0.00041; [1][20] 0.00039; [1][21] 0.00017; [1][22] -0.00008; [1][23] -0.00021; [1][24] -0.00026; [1][25] -0.00017; [1][26] -0.00001; [1][27] 0.00014; [1][28] 0.00029; [1][29] 0.00012; ; [2][0] 0.00005; [2][1] -0.00005; [2][2] -0.00018; [2][3] -0.00025; [2][4] -0.00031; [2][5] -0.00048; [2][6] -0.00033; [2][7] -0.00005; [2][8] -0.00011; [2][9] -0.00008; [2][10] 0.00005; [2][11] 0.00014; [2][12] 0.00010; [2][13] -0.00006; [2][14] -0.00008; [2][15] 0.00006; [2][16] 0.00010; [2][17] 0.00034; [2][18] 0.00022; [2][19] 0.00006; [2][20] -0.00002; [2][21] -0.00022; [2][22] -0.00025; [2][23] -0.00013; [2][24] -0.00005; [2][25] 0.00009; [2][26] 0.00016; [2][27] 0.00015; [2][28] 0.00015; [2][29] -0.00017; ;

print indicator results for tick=1338757362165[2012-06-03 21:02:42.165+0000] / 1.24188 / 1.24166

duration = 0.001118000 ms stoch= [0][0] 80.90961; [0][1] 84.92358; [0][2] 83.61338; [0][3] 75.66238; [0][4] 56.49977; [0][5] 36.48364; [0][6] 22.35144; [0][7] 21.37736; [0][8] 19.64573; [0][9] 17.34439; [0][10] 20.12748; [0][11] 29.66357; [0][12] 28.06905; [0][13] 24.11288; [0][14] 18.72041; [0][15] 36.10962; [0][16] 55.03546; [0][17] 73.73592; [0][18] 77.74093; [0][19] 80.49020; [0][20] 68.92157; [0][21] 53.72549; [0][22] 37.38358; [0][23] 31.56604; [0][24] 29.08976; [0][25] 33.91063; [0][26] 41.09866; [0][27] 56.57945; [0][28] 74.57108; [0][29] 64.70309; ; [1][0] 81.39032; [1][1] 81.52687; [1][2] 83.14886; [1][3] 81.39978; [1][4] 71.92518; [1][5] 56.21526; [1][6] 38.44495; [1][7] 26.73748; [1][8] 21.12485; [1][9] 19.45583; [1][10] 19.03920; [1][11] 22.37848; [1][12] 25.95337; [1][13] 27.28183; [1][14] 23.63411; [1][15] 26.31431; [1][16] 36.62183; [1][17] 54.96033; [1][18] 68.83744; [1][19] 77.32235; [1][20] 75.71756; [1][21] 67.71242; [1][22] 53.34355; [1][23] 40.89170; [1][24] 32.67979; [1][25] 31.52214; [1][26] 34.69968; [1][27] 43.86291; [1][28] 57.41640; [1][29] 65.28454; ;

duration = 0.001187000 ms mfi= [0] 85.79173; [1] 72.37591; [2] 59.20416; [3] 45.69092; [4] 31.11097; [5] 27.08504; [6] 25.67123; [7] 27.05753; [8] 28.06649; [9] 42.27905; [10] 55.73390; [11] 71.29635; [12] 71.42412; [13] 73.05110; [14] 86.82438; [15] 100.00000; [16] 86.24082; [17] 72.85128; [18] 73.67995; [19] 61.30206; [20] 44.67427; [21] 29.29980; [22] 26.09554; [23] 37.49803; [24] 40.42155; [25] 26.77303; [26] 37.78363; [27] 54.41968; [28] 75.14544; [29] 67.55700;

Indicator execution time > 50ms @12-06-03 17:02:42 -> 236.35636ms


I'm using jdk7-openjdk and netbeans for development on a linux machine. Hope this helps and thanks for your support.


 
 Post subject: Re: Indicator calls very slow on recent data Post rating: 0   New post Posted: Tue 09 Oct, 2012, 03:34 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
I forgot to add that the date code was changed to this for the above example:

        final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        Date dateFrom = dateFormat.parse("06/01/2012 20:00:00");
//        Date dateTo = dateFormat.parse("05/01/2012 00:01:00");
        Date dateTo = new Date();


Unrelated to this, if I stop my program execution on the last tick for June 1st, 2012 with this code:
if(1338584399796L == tick.getTime())

and then stop the program again in onBar after this I will see a bar that is marked as flat, but has volume along with different opening and closing prices and comes after the last tick. How can this be? Attached is the 5min onBar in question.

Many thanks,
mm


Attachments:
flatbar.png [18.84 KiB]
Downloaded 427 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:  

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