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.

Backtesting: Order not filled in the requested period
 Post subject: Backtesting: Order not filled in the requested period Post rating: 0   New post Posted: Fri 20 Dec, 2013, 19:34 
User avatar

User rating: 0
Joined: Tue 28 Aug, 2012, 12:34
Posts: 10
Location: Spain, Barcelona
Hi,

I'm trying to develop a system with two simple rules.
1) Buy when previous ONE_HOUR bar is a hammer and current FIFTEEN bar closes above previous one_hour bar high.
Example:
Hour bar 7:00 is a hammer with 1.44 high
7:15 bar closes 1.4405

When I submit the order in the fifteen minute period I expect to fill the order at 7:15:04 seconds (for example)
But when I check the report.html I see than the order is filled at 7:30. All orders are filled at xx:30 minutes.

My code is the following.

TesterMain.java

client.setDataInterval(Period.ONE_MIN, OfferSide.BID,
            InterpolationMethod.FOUR_TICKS, dateFrom.getTime(),
            dateTo.getTime());


Strategy.java

   final SimpleDateFormat sdfHourTwoDigits = new SimpleDateFormat("HH");
   final SimpleDateFormat sdfMinutesTwoDigits = new SimpleDateFormat("mm");
       
   sdfHourTwoDigits.setTimeZone(TimeZone.getTimeZone("GMT"));
   sdfMinutesTwoDigits.setTimeZone(TimeZone.getTimeZone("GMT"));

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

          if (period.equals(Period.FIFTEEN_MINS)) {

            String minutes = sdfMinutesTwoDigits.format(bidBar.getTime());

            // get the first 15 minutes bar after a one_hour close
       if (minutes.equals("15")) {

                 oneHourBar= history.getBar(instrument, Period.ONE_HOUR,
                  OfferSide.ASK, 0);

                 // this is when I expect to fill the order at xx:15:xx, not at xx:30:xx
                 if conditions{
                        engine.submitOrder(bean.getLabel(),
                        instrument, OrderCommand.BUY, size, 0, 5,
                        stopLossPrice, 0);
                 }

             }


          }
}


Can you help me please?


 
 Post subject: Re: Backtesting: Order not filled in the requested period Post rating: 1   New post Posted: Fri 20 Dec, 2013, 19:47 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
The method getTime returns the time of the bar beginning. So at 14:30 it will return 14:15 for 15-minutes bars.


 
 Post subject: Re: Backtesting: Order not filled in the requested period Post rating: 0   New post Posted: Sat 21 Dec, 2013, 09:53 
User avatar

User rating: 0
Joined: Tue 28 Aug, 2012, 12:34
Posts: 10
Location: Spain, Barcelona
I changed the period to one minute and now orders are filled at xx:16:xx.

Thanks hebasto!


 

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