Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Capute the bar start on Sunday evening
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=57701
Page 1 of 1

Author:  masmox [ Mon 09 Aug, 2021, 13:02 ]
Post subject:  Capute the bar start on Sunday evening

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 258 times
image2.png [104.61 KiB]
Downloaded 252 times

Author:  API Support [ Mon 27 Sep, 2021, 14:11 ]
Post subject:  Re: Capute the bar start on Sunday evening

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 135 times

  Page 1 of 1