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

what is Period.createCustomPeriod not compliant?
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=24483
Page 1 of 1

Author:  [quantisan] [ Wed 15 Dec, 2010, 15:39 ]
Post subject:  what is Period.createCustomPeriod not compliant?

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()?

Author:  API Support [ Fri 17 Dec, 2010, 11:49 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

Hi,
Custom period must be dividable by a day milliseconds count (24*60*60*1000) Because in a day all bars must be whole.

Author:  SFXbernhard [ Mon 24 Aug, 2015, 16:47 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

why does Period.createCustomPeriod(Unit.Minute, 90);
not work then?
24h/1.5h = 16

Author:  API Support [ Wed 26 Aug, 2015, 15:47 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

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);
        }

Author:  SFXbernhard [ Sun 30 Aug, 2015, 19:11 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

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

Author:  API Support [ Mon 31 Aug, 2015, 07:07 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

Only GMT timezone can be used with 90 minute charts. And we are not planning to implement compatibility with other timezones.

Author:  SFXbernhard [ Mon 31 Aug, 2015, 13:32 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

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.

Author:  API Support [ Tue 01 Sep, 2015, 13:07 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

Please set time zone to UTC in JForex platform Tools > Preferences > Charts.

Author:  SFXbernhard [ Tue 01 Sep, 2015, 15:12 ]
Post subject:  Re: what is Period.createCustomPeriod not compliant?

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?

  Page 1 of 1