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.

H4 bar timezone feed
 Post subject: H4 bar timezone feed Post rating: 0   New post Posted: Sun 13 Dec, 2015, 20:01 
User avatar

User rating: 0
Joined: Thu 05 Nov, 2015, 19:37
Posts: 2
Location: SerbiaSerbia
Hello,
Recently I started learning Java in order to develop a strategy to reduce my screen time and while I eventually did make one that works I have a problem with the H4 bar start. I isolated my problem with this code. I'm near certain there's a very simple solution for this but god knows I can't figure it out. Please help.

Attached code determines at the start of each new H4 bar if the previous bar closed bullish or bearish, and if bullish it prints "Buy." or "Sell" if bearish. However both in historical tester and when I demo forward test it, these messages are typed at 4, 8 and 12 am/pm GMT, whereas I would like them to print at 2, 6 and 10 am/pm GMT to correspond the broker bar feed.

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {

        if(!instrument.equals(Instrument.EURUSD) || !period.equals(Period.FOUR_HOURS)) return;
       
        IBar lastBar = history.getBar(Instrument.EURUSD, Period.FOUR_HOURS, OfferSide.BID, 1);
       
        if(lastBar.getClose() > lastBar.getOpen()){
            console.getOut().println("Buy.");
        }
        else if(lastBar.getClose() < lastBar.getOpen()){
            console.getOut().println("Sell.");
        }
        else;
       
    }


 
The Best Answer  Post subject: Re: H4 bar timezone feed Post rating: 0   New post Posted: Wed 16 Dec, 2015, 14:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It is possible to create custom Period with custom timezone and subscribe to it's feed.
See the attachment for an example.


Attachments:
Strategy.java [2.88 KiB]
Downloaded 95 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: H4 bar timezone feed Post rating: 0   New post Posted: Thu 17 Dec, 2015, 14:16 
User avatar

User rating: 0
Joined: Thu 05 Nov, 2015, 19:37
Posts: 2
Location: SerbiaSerbia
Thank you very much. To be honest I didn't even know you could change day start time in the platform settings.


 

Jump to:  

cron
  © 1998-2025 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