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.

About Period in onBar
 Post subject: About Period in onBar Post rating: 0   New post Posted: Mon 29 Mar, 2010, 20:51 

User rating: 0
Joined: Mon 25 Jan, 2010, 20:52
Posts: 13
In any bar we gets many number of updates/Ajdustment/changes.
How come I know in IStrategy.onBar event that this particular call is for particular bar(time period) and nextone ll be for new bar/timeperiod.

I tried above using following code

Period oldPeriod;
public void onBar(Instrument instr,Period pr, IBar askbar, IBar bidBar){
      if(oldPeriod != null && oldPeriod != pr) {
            System.out.println("New bar started");
      }
      oldperiod = pr;
}


But it is failing in 30 minute and 1 hour chart, as it returns 10 sec period on each event.

How to resolve this issue please let me know.
It is very critical for us.


 
 Post subject: Re: About Period in onBar Post rating: 0   New post Posted: Tue 30 Mar, 2010, 03:12 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
I am having the same issue with onBar( ) period stuck at 10 sec. I only have 1 chart and changing that doesn't work. How do we set the period for onBar( ) in IStrategy?


 
 Post subject: Re: About Period in onBar Post rating: 0   New post Posted: Tue 30 Mar, 2010, 12:55 

User rating: 0
Joined: Tue 30 Mar, 2010, 12:52
Posts: 2
hi -i have got exactly the same question:

how to arbitrary set the relevant period for the onBar function?


 
 Post subject: Re: About Period in onBar Post rating: 0   New post Posted: Tue 30 Mar, 2010, 13:46 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
I figured it out. onBar( ) runs on every new bar on every period. So you need to check if the period is the one you want as follow.

In main class:
    @Configurable("Period")
    public Period period = Period.ONE_MIN;


In onBar:
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if (period != this.period) {
            return;
        }


This is actually a good thing.


 
 Post subject: Re: About Period in onBar Post rating: 0   New post Posted: Tue 30 Mar, 2010, 13:53 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please note that, data will arrive for the each subscribed instrument.


 

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