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.

is there a way to get the "actual" weekly bar
 Post subject: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Wed 06 Jun, 2018, 14:01 

User rating: 0
Joined: Mon 09 Oct, 2017, 06:34
Posts: 15
Location: Hong Kong,
currently, i am testing on BTC/USD
there is a problem while getting the weekly bar
as you know the weekly/daily bar are base on GMT 00:00 as start/end time
so here is how i solve the issue, i try to get previous week market close time, and get the hour bar from weekly open and close time
let say the week bar of 20170828, market closed from 2017/09/01 21:00:00 to 2017/09/03 21:00:00
then i am going to get the hour bar of 2017/09/01 21:00:00 and 2017/09/03 21:00:00
so i can get the actual weekly open and close price
but for week bar of 20170828 as example, the actual open time of next week which the first tick suppose to be
2017/09/03 21:00:00, but the first tick of this week are actually 2017/09/04 00:00

is that a bug? and is there exist a way to get the actual bar?, what i want is just getting the weekly open and close price
tks


 
 Post subject: Re: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Wed 06 Jun, 2018, 17:19 

User rating: 4
Joined: Wed 23 May, 2018, 20:08
Posts: 44
Location: FinlandFinland
Hello,

I had hard time undertanding your question. Here is something that I hope gives you direction.

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
         if (!instrument.equals(Instrument.EURUSD) || !period.equals(Period.WEEKLY)){
                return;
         }
         console.getOut().println("W1-Close: " + askBar.getClose() +" W1-Open" + askBar.getOpen());
 
    }
}


https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IStrategy.html


 
 Post subject: Re: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Wed 06 Jun, 2018, 18:52 

User rating: 0
Joined: Mon 09 Oct, 2017, 06:34
Posts: 15
Location: Hong Kong,
tks, but the onBar method are start/end at GMT 00:00
but the weekly/daily bar are start/end at GMT 21:00

if you use the daily IBar from onBar method it will cause the following issue
let say the week of 20180604
the daily IBar of monday(20180604) will be from 20180603 GMT 00:00 to 20180604 GMT 00:00
and from 20180603 GMT 00:00 to 20180603 GMT 21:00, market are closed
that why the IBar from onBar method are not reliable


 
 Post subject: Re: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Wed 06 Jun, 2018, 19:38 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
Maybe try to get weekly bar from history.getBar() shift 0
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       
        // in here - 0 is current bar, 1 is previous candle, 2 second prev candle etc https://www.dukascopy.com/wiki/en/development/strategy-api/historical-data/history-bars
        IBar weeklyBar = history.getBar(instrument, Period.WEEKLY, OfferSide.BID, 0);
        console.getOut().println( weeklyBar );
       
        if (period.equals(Period.WEEKLY)) {
            console.getOut().println( bidBar );
        }
}


 
 Post subject: Re: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Wed 13 Jun, 2018, 14:16 

User rating: 0
Joined: Mon 09 Oct, 2017, 06:34
Posts: 15
Location: Hong Kong,
can API support help?


 
 Post subject: Re: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Thu 14 Jun, 2018, 12:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,

Let's see at your example. Weekly bar of 20170828 will be in a time interval from 28.08.2017 00.00 GMT to 04.09.2017 00:00 GMT. First tick of 28.08 also is a bar open price, last tick of 03.09 is a bar close price. In a period from 01.09.2017 21:00 to 03.09.2017 21:00 market is closed, but ticks from last 3 hours of 03.09 also is this bar filling. And next bar of 20170409 will be in a interval 04.09.2017 00:00 to 11.09.2017 00:00.

If you want specify weekly interval exactly from Sunday 21.00 to next Sunday 21.00 you can use custom period with EET timezone, which will work in accordance with your conditions.
Here you can read about custom period creation: https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=56510
        Period myPeriod = Period.createCustomPeriod(Unit.Week, 1, JFTimeZone.EET);
        IBar weeklyBar = history.getBar(instrument, myPeriod, OfferSide.ASK, 0);
        console.getOut().println(weeklyBar);

And you will get weekly bar with start time of Sunday 21:00 GMT.


 
 Post subject: Re: is there a way to get the "actual" weekly bar Post rating: 0   New post Posted: Mon 18 Jun, 2018, 06:24 

User rating: 0
Joined: Mon 09 Oct, 2017, 06:34
Posts: 15
Location: Hong Kong,
tks, and this is also my solution, but i use EAT time zone lead to an unexpected result, BTW can you tell me are dukascopy trading server using EET time zone? let say the weekly bar of 2018/03/04, the starting time are GMT 22:00 and changed to 21:00 at next week, is that same as dukascopy summer/winter time changing? since i don't know when did dukascopy changing the summer/winter time


 

Jump to:  

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