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.

Capute the bar start on Sunday evening
 Post subject: Capute the bar start on Sunday evening Post rating: 0   New post Posted: Mon 09 Aug, 2021, 13:02 

User rating: 0
Joined: Mon 09 Aug, 2021, 12:16
Posts: 1
Location: Italy, Verona
Hello, this is my frist post here.
I'd like to capture on the XAU/USD the open bar that start on Sunday evening. I've the platform set GMT and Day Start Time of the chart set on EET.
I've a simple code that print on the console the previous open price and the current open price using history.getBar(myInstrument, Period.Daily, OfferSide.BID, 0).
My backtest start on 01/01/2021 00:00.


public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException
    {

        try {
           
             if (!instrument.equals(myInstrument) || !period.equals(cfgMyPeriod)) {

                return; //quit

            }
             
           
            printMe("Open Previous Bid: "+bidBar.getOpen());
           
            IBar CurrentDaily = history.getBar(myInstrument, Period.Daily, OfferSide.BID, 0);
            printMe("Current Bar "+CurrentDaily);
           
           
        } catch (Exception ex) {

        }

    }



Form the after the bar start is possible to see in the console the open price 1904.998 (see red arrow), as the OHLC widget report, isn't reported.

Image

I can capture the price 1904,998 only after I received the tick time related to 2021-01-04, see the image2 attached. But of course this is non my intention because I want capture the start of the Sunday evening bar when it start and not after some hour.
Image

The same behavior if a set the Daily start time zone to GMT. The difference is on the char where the bar of the sunday and of the monday are splitted.

Please can someone help me?

Thankyou


Attachments:
image1.png [99.95 KiB]
Downloaded 24 times
image2.png [104.61 KiB]
Downloaded 23 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: Capute the bar start on Sunday evening Post rating: 0   New post Posted: Mon 27 Sep, 2021, 14:11 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6118
Greetings.

IStrategy.onBar() method receives candles for UTC time zone.
Period.Daily also refers to period with UTC time zone.

Your strategy must subscribe to custom period data feed to receive daily candles with EET time zone.
See attached example CustomPeriodTest.java

Regards.


Attachments:
CustomPeriodTest.java [2.26 KiB]
Downloaded 13 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.
 

Jump to:  

  © 1998-2011 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