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.

onBar - Range Bars
 Post subject: onBar - Range Bars Post rating: 0   New post Posted: Mon 28 Nov, 2011, 15:14 

User rating: 0
Joined: Tue 22 Nov, 2011, 12:47
Posts: 130
Location: United States,
hi,

I'm opening a chart on EUR/USD with Range Bars.

I am running a simple strategy and print our the bars that I get in the method onBar.

To my surprise - the onBar method is not called on new Range Bars formation BUT instead it is called on 10 sec bars -

14:12:19 >>onBar: New Bar[EUR/USD]: 1322489530000[2011-11-28 14:12:10.000+0000] O: 1.33884 C: 1.3388 H: 1.33884 L: 1.3388 V: 38.24 period: 10 Secs
14:12:10 >>onBar: New Bar[EUR/USD]: 1322489520000[2011-11-28 14:12:00.000+0000] O: 1.3389 C: 1.33883 H: 1.3389 L: 1.33883 V: 43.41 period: 10 Secs
14:12:00 >>onBar: New Bar[EUR/USD]: 1322489510000[2011-11-28 14:11:50.000+0000] O: 1.33892 C: 1.3389 H: 1.33894 L: 1.33888 V: 32.2 period: 10 Secs

Why is that?


 
 Post subject: Re: onBar - Range Bars Post rating: 0   New post Posted: Mon 28 Nov, 2011, 15:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please provide a source code example.


 
 Post subject: Re: onBar - Range Bars Post rating: 0   New post Posted: Mon 28 Nov, 2011, 16:16 

User rating: 0
Joined: Tue 22 Nov, 2011, 12:47
Posts: 130
Location: United States,
here you go: (please run it on a chart which is set to Range Bars)

package jforex;

import java.util.*;

import com.dukascopy.api.*;

public class Empty implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;
   private IUserInterface userInterface;
   
   public void onStart(IContext context) throws JFException {
      this.engine = context.getEngine();
      this.console = context.getConsole();
      this.history = context.getHistory();
      this.context = context;
      this.indicators = context.getIndicators();
      this.userInterface = context.getUserInterface();
   }

   public void onAccount(IAccount account) throws JFException {
   }

   public void onMessage(IMessage message) throws JFException {
   }

   public void onStop() throws JFException {
   }

   public void onTick(Instrument instrument, ITick tick) throws JFException {
   }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       context.getConsole().getOut().println(bidBar);
    }
}


 
 Post subject: Re: onBar - Range Bars Post rating: 0   New post Posted: Mon 28 Nov, 2011, 16:34 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In onBar you receive candle stick bars over all the strandard periods on all subscribed instruments - regardless of what you have on the chart. In order to receive range bars, you need to subscribe to them and range bars have their own onBar method, see:
https://www.dukascopy.com/wiki/index.php ... Range_Bars


 
 Post subject: Re: onBar - Range Bars Post rating: 0   New post Posted: Mon 28 Nov, 2011, 17:07 

User rating: 0
Joined: Tue 22 Nov, 2011, 12:47
Posts: 130
Location: United States,
yes - thanks support. works great.


 

Jump to:  

  © 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