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.

Reading bars
 Post subject: Reading bars Post rating: 0   New post Posted: Tue 21 Jun, 2016, 22:37 
User avatar

User rating: 0
Joined: Fri 04 Sep, 2015, 19:44
Posts: 34
Location: Slovakia, KE
Hi
I don' know how to use "bar reading" functions. Im comfused.

A) reading completed bars from history?
B) reading (uncompleted"future") bars "real time" after order close?

?
What if i want 5 bars or 3 bars ? (/5 min) instead of 1 and compare price ?

How to close orders automatically - after reached SL andTP or 4 hours? I only found in Miliseconds.

I can't find any code for this.


 
 Post subject: Re: Reading bars Post rating: 0   New post Posted: Wed 22 Jun, 2016, 14:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It is described here
https://www.dukascopy.com/wiki/#History_bars

To get the currently forming bar time parameter of
getBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter)
must be equal to the start time of currently forming candle.
    public void onTick(Instrument instrument, ITick tick) throws JFException {        
        long lastBarStart = history.getBarStart(Period.ONE_HOUR, tick.getTime() );
        print("last bar start", lastBarStart);
        List<IBar> bars = history.getBars(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, Filter.NO_FILTER, 3, lastBarStart, 0);
        for(IBar bar : bars) {
            print(bar);
        }               
    }

See a full example in the attachment.


Attachments:
Strategy.java [5.65 KiB]
Downloaded 91 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Reading bars Post rating: 0   New post Posted: Thu 23 Jun, 2016, 08:32 
User avatar

User rating: 0
Joined: Fri 04 Sep, 2015, 19:44
Posts: 34
Location: Slovakia, KE
Thanks.
Why on tick()?
What does print(bar) do?


 
 Post subject: Re: Reading bars Post rating: 0   New post Posted: Mon 27 Jun, 2016, 08:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
onTick() is used to see how IBar.getClose() price changes for the bar with index 0.
print(bar) prints bar's data, print is custom method given in the attached strategy.


 

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