Dukascopy
 
 
Wiki JStore Search Login

Remote Run. onStart tick is NULL
 Post subject: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Thu 26 Sep, 2013, 18:32 

User rating: 1
Joined: Sun 20 May, 2012, 09:29
Posts: 22
Location: Czech Republic, programmer
Dear support team,

When starting strategy using "Remote Run", in onStart method can not get TICK from history.
@Override
public void onStart(IContext context) throws JFException {

    ITick tick = context.getHistory().getTick(instrument, 0);
}


In this case TICK is NULL.
Please, can you check it?


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Thu 26 Sep, 2013, 18:35 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi:

Try to get tick information after the strategy has subscribed the instrument. If done forget this post.

Trade well

JL


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Thu 26 Sep, 2013, 18:46 

User rating: 1
Joined: Sun 20 May, 2012, 09:29
Posts: 22
Location: Czech Republic, programmer
jlongo wrote:
Hi:

Try to get tick information after the strategy has subscribed the instrument. If done forget this post.

Trade well

JL


Thanks for quick reply.
In real strategy I try to get tick after subscribing to instruments.


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Thu 26 Sep, 2013, 18:49 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi:

Sometimes subscribing can take some time...
You can try to see if instrument is subscribed before try to get tick information.

Trade well

JL


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Thu 26 Sep, 2013, 19:00 

User rating: 1
Joined: Sun 20 May, 2012, 09:29
Posts: 22
Location: Czech Republic, programmer
jlongo wrote:
Hi:

Sometimes subscribing can take some time...
You can try to see if instrument is subscribed before try to get tick information.

Trade well

JL


I use code below to subscribe to instruments
    context.setSubscribedInstruments(instruments);

    // wait max 1 second for the instruments to get subscribed
    int i = 10;
    while (!context.getSubscribedInstruments().containsAll(instruments) && i >= 0) {
      try {
        console.getOut().println("Instruments not subscribed yet " + i);
        Thread.sleep(1000);
      }
      catch (InterruptedException e) {
        console.getOut().println(e.getMessage());
      }
      i--;
    }


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Thu 26 Sep, 2013, 19:06 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
I do not see any reasonable explication to be unable to get tick information if you try to get it after that code...
lets see if support has anything to say.

Trade well

JL

EDIT: instead of context.getHistory().getTick(instrument, 0); try with context.getHistory().getLastTick(instrument); it gets last tick received by the strategy. current tick (shift 0) sounds a litle ambiguos to me as at that time the method is called exist the possibility of no existing tick.


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 0   New post Posted: Fri 27 Sep, 2013, 07:31 

User rating: 1
Joined: Sun 20 May, 2012, 09:29
Posts: 22
Location: Czech Republic, programmer
jlongo wrote:
EDIT: instead of context.getHistory().getTick(instrument, 0); try with context.getHistory().getLastTick(instrument); it gets last tick received by the strategy. current tick (shift 0) sounds a litle ambiguos to me as at that time the method is called exist the possibility of no existing tick.

Both methods return NULL.
Ticks in History available only after onTick method execution.


 
 Post subject: Re: Remote Run. onStart tick is NULL Post rating: 1   New post Posted: Wed 16 Oct, 2013, 22:25 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
Try this snippet for your onStart() method:
        //wait max 10 secs
        for (int i = 10; i > 0; i--) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                context.getConsole().getOut().println(e.getMessage());
            }
            if (context.getHistory().getLastTick(instrument) != null) break;
        }


 

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