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.

How to get the current in progress bar and receive updates to it?
 Post subject: How to get the current in progress bar and receive updates to it? Post rating: 0   New post Posted: Tue 26 Sep, 2017, 11:18 

User rating: 0
Joined: Mon 29 May, 2017, 17:19
Posts: 21
Location: Germany,
I have been using onBar() to get bars, but there seems to be no option to get the current forming bar. I *think* I can get the current forming bar from the feed (haven't tested it yet) but as far as I could research, it will only provide the bar as it was in that moment of time when I requested it, but not update it. Is there a way I can get and update the currently forming bar, or do I have to construct one myself using onTick() as source?

Another question: when should I use onTick()/onBar() and when should I use a Feed?

Thanks!


 
 Post subject: Re: How to get the current in progress bar and receive updates to it? Post rating: 1   New post Posted: Tue 26 Sep, 2017, 14:43 
User avatar

User rating: 2
Joined: Tue 11 Jul, 2017, 09:30
Posts: 24
Location: HungaryHungary
As far as I know, you get the last not finished bar automatically:

"
The getBar method returns an IBar by shift. Shift of value 0 refers to the current candle that's not is not yet fully formed, 1 - latest fully formed candle, 2 - second to last candle. Consider retrieving previous 1 hour bar for EUR/USD:

"

https://www.dukascopy.com/wiki/en/development/strategy-api/historical-data/history-bars

Use onTick, if you want to use the tick, which isn't a period, but a point in time.
Use onBar for default periods.
Use onFeed for custom periods, you have to subscribe for them.
https://www.dukascopy.com/wiki/en/development/strategy-api/historical-data/feed-history


 
 Post subject: Re: How to get the current in progress bar and receive updates to it? Post rating: 0   New post Posted: Tue 26 Sep, 2017, 18:26 

User rating: 0
Joined: Mon 29 May, 2017, 17:19
Posts: 21
Location: Germany,
Thanks for your reply!

I must have overseen that getBar() with a shift of 0 gets the currently forming candle. I did some tests but it seems like that IBar that it gives back is not updated when high, low, or close change, though. If this is the case then I see only two ways to get an updated IBar is by:
1. requesting a new one every time a new tick for that symbol comes in or
2. update the bar information myself by using the tick data

Or do I miss something?

Thanks for clearing up when to use Feeds.


 
 Post subject: Re: How to get the current in progress bar and receive updates to it? Post rating: 1   New post Posted: Wed 27 Sep, 2017, 07:06 
User avatar

User rating: 2
Joined: Tue 11 Jul, 2017, 09:30
Posts: 24
Location: HungaryHungary
I my view: the getBar is updated only when the function is called, where the getBar is. So if you want "continuous" update of the forming candle, you have to place it in onTick.

(But wait some official response, I am not a JForex pro.)


 

Jump to:  

cron
  © 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