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.

what is Period.createCustomPeriod not compliant?
 Post subject: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Wed 15 Dec, 2010, 15:39 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
I tried to create a custom 7 seconds period using:
Period.createCustomPeriod(Unit.Second, 7);

Then I got an error saying the period is not compliant with Daily.

What does that mean? How do I fix it? What is a compliancy period as said in Period.getCompliancyPeriod()?


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Fri 17 Dec, 2010, 11:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Custom period must be dividable by a day milliseconds count (24*60*60*1000) Because in a day all bars must be whole.


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Mon 24 Aug, 2015, 16:47 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
why does Period.createCustomPeriod(Unit.Minute, 90);
not work then?
24h/1.5h = 16


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Wed 26 Aug, 2015, 15:47 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Could you please elaborate.
Here is an example that works.
        Period period = Period.createCustomPeriod(Unit.Minute, 90); 
        Instrument instrument = Instrument.EURUSD;       
       
        Calendar cal = new GregorianCalendar();
        cal.set(2015,Calendar.JUNE,9,0,0,0);
        long from = history.getBarStart(period,cal.getTimeInMillis());
        long to1 = history.getBar(instrument,period,OfferSide.BID,1).getTime();
       
        List bars = history.getBars(instrument, period, OfferSide.BID, from, to1);
       
        for(Object o : bars) {
            console.getOut().println(o);
        }


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Sun 30 Aug, 2015, 19:11 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
See the following example. 90 min chart does not open!
I used the current JForex 2.45.15
Please fix this bug.

package jforex;

import java.util.*;

import java.util.ArrayList;
import java.util.List;

import com.dukascopy.api.*;
import com.dukascopy.api.chart.*;
import com.dukascopy.api.feed.util.*;
import com.dukascopy.api.feed.*;
import com.dukascopy.api.feed.util.*;
import com.dukascopy.api.Period.*;
import com.dukascopy.api.Unit.*;


public class Strategy90MinutenS implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    private IConsole con = null;
   
    public void onStart(IContext context) throws JFException { 
        this.context = context;   
        history = context.getHistory();
        indicators = context.getIndicators();   
   
        Period NeunzigMinutePeriode = Period.createCustomPeriod(Unit.Minute,90);
        IFeedDescriptor NeunzigMinutefeedDescriptor = new TimePeriodAggregationFeedDescriptor(Instrument.EURUSD, NeunzigMinutePeriode, OfferSide.BID);
        IChart NeunzigMinuteChart = context.openChart(NeunzigMinutefeedDescriptor);
    }   
    public void onStop() throws JFException {
    }   
    public void onAccount(IAccount account) throws JFException {
    }
    public void onMessage(IMessage message) throws JFException {
    }
    public void onTick(Instrument instr, ITick tick) throws JFException {
    }   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}

Image


Console throws the following exception

java.lang.IllegalArgumentException: JFTimeZone is not appropriate for this unit. Received Unit = Minute, numOfUnits = 90, JFTimeZone = EET with standard offset -7200000(milliseconds) and daylight offset -10800000(milliseconds). Offsets cannot be other than 0 for periods with Unit smaller than Unit.Day.
   at com.dukascopy.api.Period.createCustomPeriod(Period.java:372)
   at com.dukascopy.charts.chartbuilder.a.<init>(L:259)
   at com.dukascopy.charts.main.DDSChartsControllerImpl.b(L:862)
   at com.dukascopy.charts.main.DDSChartsControllerImpl.a(L:114)
   at com.dukascopy.dds2.greed.gui.component.widget.chart.ChartWidget.buildChart(L:196)
   at com.dukascopy.dds2.greed.gui.component.widget.chart.ChartWidget.setChartBean(L:120)
   at com.dukascopy.dds2.greed.gui.component.chart.g.a(L:848)
   at com.dukascopy.dds2.greed.gui.component.chart.g.a(L:327)
   at com.dukascopy.dds2.greed.gui.component.tree.actions.b.b(L:78)
   at com.dukascopy.dds2.greed.gui.component.tree.actions.b.T(L:43)
   at com.dukascopy.dds2.greed.gui.component.tree.actions.ax.execute(L:35)
   at com.dukascopy.dds2.greed.gui.helpers.h.p(L:790)
   at com.dukascopy.dds2.greed.gui.component.chart.g.f(L:332)
   at com.dukascopy.api.impl.connect.at.bk(L:180)
   at com.dukascopy.api.impl.connect.at.run(L:172)
   at java.security.AccessController.doPrivileged(Native Method)
   at com.dukascopy.api.impl.connect.ar.openChart(L:172)
   at com.dukascopy.api.impl.connect.ax.run(L:201)
   at java.awt.event.InvocationEvent.dispatch(Unknown Source)
   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
   at java.awt.EventQueue.access$300(Unknown Source)
   at java.awt.EventQueue$3.run(Unknown Source)
   at java.awt.EventQueue$3.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)



Attachments:
150830bug.png [18.09 KiB]
Downloaded 358 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: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Mon 31 Aug, 2015, 07:07 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Only GMT timezone can be used with 90 minute charts. And we are not planning to implement compatibility with other timezones.


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Mon 31 Aug, 2015, 13:32 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
JForex Platform time zone is "GMT (UTC)"!
I also tried the following change, but it did not work either.
Period NeunzigMinutePeriode = Period.createCustomPeriod(Unit.Minute,90, JFTimeZone.UTC );       


Please clarify what must I do to open a 90 min chart.
It seems more like a bug to me at the moment.


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Tue 01 Sep, 2015, 13:07 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please set time zone to UTC in JForex platform Tools > Preferences > Charts.


 
 Post subject: Re: what is Period.createCustomPeriod not compliant? Post rating: 0   New post Posted: Tue 01 Sep, 2015, 15:12 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
This helped. But why do you set the Day Start Time to EET (UTC+2h) by default?
I never changed it.
Shouldn't this be UTC to avoid confusions like this?


 

Jump to:  

  © 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