Dukascopy
 
 
Wiki JStore Search Login

Get Bars with Filter.WEEKENDS
 Post subject: Get Bars with Filter.WEEKENDS Post rating: 0   New post Posted: Wed 10 Jul, 2013, 14:21 

User rating: 2
Joined: Wed 05 Jun, 2013, 12:27
Posts: 9
Hello,

I am trying to get the bars in an interval of dates but without the weekend data.

My strategy is exactly the same that this one (Multiple candle periods), but with Filter.
        for(Period period : periods){
            long timeCandle = dataService.getTimeOfFirstCandle(Instrument.EURUSD, period);
            List<IBar> bars = null;
            List<IBar> filteredBars = null;
            try{
                long from = history.getBarStart(period, timeCandle + period.getInterval());
                long to = history.getBarStart(period, timeCandle + 2 * period.getInterval());
                bars = history.getBars(Instrument.EURUSD, period, OfferSide.BID, from, to);
                filteredBars = history.getBars(Instrument.EURUSD, period, OfferSide.BID, Filter.WEEKENDS,from, to);
            } catch (JFException e){
                console.getErr().println(e);
            }
where periods is:
Period[] periods = new Period[]{
             ONE_SEC, ONE_MIN, FIVE_MINS, TEN_MINS, FIFTEEN_MINS, THIRTY_MINS, ONE_HOUR, FOUR_HOURS, DAILY, WEEKLY, MONTHLY
    };
The conflicting line is:
filteredBars = history.getBars(Instrument.EURUSD, period, OfferSide.BID, Filter.WEEKENDS,from, to);
That line works fine for Period.ONE_SEC, but for the other periods it gives me the exception:
com.dukascopy.api.JFException: Requested time interval from [2003-08-11 00:02:00:000] to [2003-08-11 00:03:00:000] GMT is not valid
I attach my strategy in case it helps. I would appreciate any suggestion or a different approach to achieve this.

Thank you


Attachments:
FirstDataTimesMultiPeriods.java [2.12 KiB]
Downloaded 323 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:  

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