How to create a 4 hour strategy using a day start time EET

I would like to create a strategy that works in the timeframe of 4 hours.
In this timeframe the first bar of the week starts the 11 December (Sunday) at 22:00h.
I am using a platform time zone GMT(UTC) with a chart day start time EET.

The problem is that the strategy that I create starts using the first bar the 11 December (Sunday) at 20:00h.

The strategy execute the bars in this order: 11/12/2016 20:00h, 12/12/2016 00:00h, 12/12/2016 04:00h while the chart show the bars in this way : 11/12/2016 22:00h, 12/12/2016 02:00h, 12/12/2016 06:00h.

I try to create a custom period like this

private JFTimeZone myJFTimeZone = JFTimeZone.EET;
private Period myPeriod = Period.createCustomPeriod(Unit.Hour,4,myJFTimeZone);

But not work well because any bar arrival.

if (!instrument.equals(myInstrument) || !period.equals(myPeriod) ) {
return; //quit

Translate to English Show original

orto leave comments

Answers: 1

Best Answer

One way of doing this would be to use hourly bars and introduce checkTime method which returns true when hourly bar time matches 4 hour EET bar time.

if (instrument.equals(myInstrument) && period.equals(Period.ONE_HOUR) && checkTime(askBar.getTime())) {
// strategy code

Translate to English Show original
16 Dec. 2016 by

orto leave comments
Please log in or register to post answer.