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.

Creating Tick Level Indicators
 Post subject: Creating Tick Level Indicators Post rating: 0   New post Posted: Mon 26 Jan, 2009, 16:45 

User rating: 0
Joined: Mon 15 Dec, 2008, 16:59
Posts: 11
Hello,

Similar to a bar problem I have a few weeks back, when I create an indicator at tick level in OnTick, I get this error:

com.dukascopy.api.JFException: "to" parameter can't be greater than time of the last tick for this instrument

but my 'to' parameter is set to the time of the current tick in the call tick.getTime(). It also fails on tick.getTime()-1

Obviously I need the indicator to calculate right up to the most recent tick for the service to be responsive.

Thanks


 
 Post subject: Re: Creating Tick Level Indicators Post rating: 0   New post Posted: Tue 27 Jan, 2009, 09:28 
User avatar

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

make sure that your indicator and the tick that you use for time has the same instrument


 
 Post subject: Re: Creating Tick Level Indicators Post rating: 0   New post Posted: Tue 27 Jan, 2009, 11:29 

User rating: 0
Joined: Mon 15 Dec, 2008, 16:59
Posts: 11
I use the Instrument and ITick parameters passed into the OnTick call to create the indicator. The 'to' time comes from the tick.getTime().

The indicator is only created without error if I use tick.getTime()-1000 instead, which causes a delay to my signals.


 
 Post subject: Re: Creating Tick Level Indicators Post rating: 0   New post Posted: Tue 27 Jan, 2009, 11:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Could you please post the code where you call indicator?


 
 Post subject: Re: Creating Tick Level Indicators Post rating: 0   New post Posted: Tue 27 Jan, 2009, 11:37 

User rating: 0
Joined: Mon 15 Dec, 2008, 16:59
Posts: 11
See below...

package jforex;

import java.util.*;

import com.dukascopy.api.*;

public class TestIndicators implements IStrategy {
   private IContext context = null;
   private IEngine engine = null;
   private IChart chart = null;
   private IIndicators indicators = null;
   private IHistory history = null;
   int calcWindowMs = 60000;

   public void onStart(IContext context) throws JFException {
      this.context = context;
      engine = context.getEngine();
      indicators = context.getIndicators();
      history = context.getHistory();   
   }

   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 {
      double[] t3 = indicators.t3(instrument, Period.TICK, OfferSide.ASK, IIndicators.AppliedPrice.CLOSE, 20, 0.95, tick.getTime()-calcWindowMs, tick.getTime());      
   }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}


 
 Post subject: Re: Creating Tick Level Indicators Post rating: 0   New post Posted: Wed 28 Jan, 2009, 17:07 

User rating: 0
Joined: Mon 15 Dec, 2008, 16:59
Posts: 11
I have found that even going back as far as 5 ticks or more in time isn't always early enough for the indicator to calculate properly.

It should calculate right up to the tick in the OnTick() call.


 

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