Feed history

One can retrieve history of all additional data feeds (i.e. besides candle stick and tick feeds) that are available in platform:

  • range bars,
  • tick bars,
  • point and figure columns,
  • renko bars (bricks).
  • kagi bars
  • line break bars
  • price aggregation bars

Data units can be loaded by shift, time interval and unit interval, reflecting the principles of candlestick bar loading. Data can be loaded both synchronously and asynchronously. See History bars article for synchronous vs asynchronous loading considerations. For more performant historical feed loading, consider subscribing to the respective data feed first.

Note: the functionality described in this article is available with JForex-API 2.6.49.

Since the feed loading principles highly resemble the ones of candlestick bar loading, then in this section we only provide a few snippets.

Feed by shift and unit interval

public class FeedHistory implements IStrategy, IFeedListener {

    private IConsole console;
    private IHistory history;
    int dataCount = 0;

    @Configurable(value = "feed type", description = "choose any type of feed (except ticks) in the strategy parameters dialog")
    public IFeedDescriptor feedDescriptor = new RangeBarFeedDescriptor(Instrument.EURUSD, PriceRange.TWO_PIPS, OfferSide.ASK);    

    public void onStart(final IContext context) throws JFException {
        history = context.getHistory();
        console = context.getConsole();
        context.setSubscribedInstruments(java.util.Collections.singleton(feedDescriptor.getInstrument()), true);

        //the subscription important for enabling feed caching - hence history method performance
        context.subscribeToFeed(feedDescriptor, this); 

        ITimedData lastFeedData = history.getFeedData(feedDescriptor, 0); //currently forming feed element
        List<ITimedData> feedDataList = history.getFeedData(feedDescriptor, 3, lastFeedData.getTime(), 0);

        console.getOut().format("%s current=%s \n previous 3 elements=%s", 
                        feedDescriptor.getDataType(), lastFeedData, feedDataList).println();        


    public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) {}


Feed asynchronous loading

Consider loading the feed asynchronously for the last day:

ITimedData lastFeedData = history.getFeedData(feedDescriptor, 0); //currently forming feed element
final long from = lastFeedData.getTime() - TimeUnit.DAYS.toMillis(1), to = lastFeedData.getTime();
history.readFeedData(feedDescriptor, from, to, 
     new IFeedListener(){
         public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) {
     new LoadingProgressListener(){
         public void dataLoaded(long start, long end, long currentPosition, String information) {

         public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) {
                 console.getOut().format("%s - %s %s %s feed elements loaded", 
                         DateUtils.format(from), DateUtils.format(from), dataCount, feedDescriptor.getDataType()).println();

         public boolean stopJob() {
             return false;


Tick bars of chart by shift

Consider a startegy which writes on chart how many ticks are remaining in the current tick bar. Note that the tick bar size gets taken from the chart.

public void onTick(Instrument instrument, ITick tick) throws JFException {        
    if(instrument != this.instrument){

    if(chart == null || chart.getTickBarSize() == null){
        console.getOut().println("Tick bar chart not opened!");

    ITickBar currentTickBar = history.getTickBar(instrument, OfferSide.BID, chart.getTickBarSize(), 0);
    int remaining =  (int) (chart.getTickBarSize().getSize() - currentTickBar.getFormedElementsCount());
    console.getOut().println("ticks remaining: " + remaining + " currentTickBar: " + currentTickBar);
    chart.comment("Ticks remaining " + remaining);



The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.