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.

Problem with OnTick
 Post subject: Re: Problem with OnTick Post rating: 0   New post Posted: Thu 28 May, 2009, 15:55 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
does
getLastTick(Instrument instrument)
return the last tick that was triggered in onTick on the client's side,
or the real last tick that was processed by the DK-server?

If getLastTick contains the last processed tick on the server, the following code would retrieve the missing ticks:
   ...
   private IHistory history = null;
   ...
   private long glLastTickTimeProcessed = 0;
   ...

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

   ...

   public void onTick(Instrument _instrument, ITick _tick) throws JFException
   {
        if (glLastTickTimeProcessed != 0 && glLastTickTimeProcessed != history.getLastTick(_instrument))
        {
           List<ITick> alMissedTick = history.getTicks(_instrument, glLastTickTimeProcessed + 1, _tick.getTime() - 1);
           //... add code to process missed ticks here...
        }
        glLastTickTimeProcessed = _tick.getTime();
       
        //... further processing of current tick...
   }


Alternatively DukasCopy could maybe make this available through a new function (if this could provide a faster way to collect and access the missed ticks):
List>ITick> IHistory.getLastTicksMissed(Instrument instrument)
and ...
Long IHistory.getLastTicksMissedCount(Instrument instrument)
as a fast way to get the number of missed ticks without having to load them and maybe take action depending on the number of missed tick...

Best, RR.


 
 Post subject: Re: Problem with OnTick Post rating: 0   New post Posted: Fri 29 May, 2009, 00:41 

User rating: 0
Joined: Mon 03 Mar, 2008, 00:39
Posts: 6
  long LastTime = history.getTimeOfLastTick(instrument);
 
  List<ITick> ticks;
 
  try {
    ticks = history.getTicks(instrument, BeginTime, LastTime);
  } catch (JFException e) {
    e.printStackTrace(console.getErr());
    //init ticks with empty list (check if this is ok)
    ticks = new ArrayList<ITick>();
    ticks.add(history.getLastTick(instrument));
  }

  BeginTime = LastTime;


 
 Post subject: Re: Problem with OnTick Post rating: 0   New post Posted: Mon 08 Jun, 2009, 09:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello , right - history functions have all ticks!
temp - thanks for help - code is good.


 
 Post subject: Re: Problem with OnTick Post rating: 0   New post Posted: Thu 11 Jun, 2009, 21:35 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
I've got the following questions regarding the availability of ticks in IHistory and in IIndicator:

1) Is at the time a tick is passed to onTick, this very tick always already available in IHistory
or could there be a delay until the current tick in onTick is also retrievable in IHistory?

2) If during the processing of a tick in onTick newer ticks are generated on the platform,
will the new ticks instantly be available in IHistory,
so that IHistory can contain ticks that are newer than the currently processing one?

3) Is it then also possible for indicator values to contain newer ticks then the one that is processed in onTick?
If during an onTick processing a new tick is generated that forms a bar, this would cause the indictorvalue
from then on to contain this new bar?
If so, this would mean that the indicator-values could change during an onTick-processing.


 
 Post subject: Re: Problem with OnTick Post rating: 0   New post Posted: Mon 15 Jun, 2009, 10:55 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
1) Yes, it is always available
2) yes, it can contain newer ticks
3) if you ask indicator with function that uses shift parameter, then yes it always contains the latest value. If you ask indicator value two times during onTick processing then there is a chance that it will be different


 

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