Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Bad data in Renko feed
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=85&t=50994
Page 2 of 5

Author:  tcsabina [ Fri 25 Apr, 2014, 18:35 ]
Post subject:  Re: Bad data in Renko feed

Dear Support,

Could you give us an estimation about when will the 'fix' be available? I am talking about the issue of the feedData (not being the last formed brick).

@scotpip
thumbs up for the detailed, thorough testing and explanation!

Author:  Platform Support [ Tue 29 Apr, 2014, 07:16 ]
Post subject:  Re: Bad data in Renko feed

It should be ready in few weeks on JForex4. Will implement in old JForex right after.

Author:  jamesadk [ Wed 28 May, 2014, 16:00 ]
Post subject:  Re: Bad data in Renko feed

Dear support,

Do you have any further update as to when this bug will be fixed?

Many thanks

@scotpip
to echo what has been said by @tcsabina, well done on pressing with this, many thanks. Without this bug being fixed all renko system are essentially worthless.

Author:  Platform Support [ Mon 02 Jun, 2014, 09:12 ]
Post subject:  Re: Bad data in Renko feed

Coming in JForex 4 version 4.08 for testing. Planned to be deployed next week.

Author:  scotpip [ Mon 02 Jun, 2014, 12:40 ]
Post subject:  Re: Bad data in Renko feed

Thanks for the update!

Author:  Platform Support [ Tue 17 Jun, 2014, 14:12 ]
Post subject:  Re: Bad data in Renko feed

Available on JForex4, version 4.08

You are welcome to leave your feedback here: viewtopic.php?f=200&t=51402

Author:  giorgio58 [ Tue 17 Jun, 2014, 19:28 ]
Post subject:  Re: Bad data in Renko feed

Good evening,
I tried to run a test with JForex4 4.08 using a procedure running in JForex but
I received an error message "Error in strategy: java.lang.NullPointerException at null"

Has anything changed in RenkoFeedDescriptor?


Messages:
17/06/2014 18:20:20   Strategy "RenkoTest" is stopped at 2014-06-17 18:20:20.469 GMT on the local computer with parameters ""=[FeedDescriptor [dataType=RENKO, instrument=EUR/JPY, offerSide=Bid, priceRange=THREE_PIPS, ]]
17/06/2014 18:20:20   Stopping "RenkoTest" strategy at 2014-06-17 18:20:20.447 GMT on the local computer
17/06/2014 18:20:20   Error in strategy: java.lang.NullPointerException at null
17/06/2014 18:20:20   Starting strategy: singlejartest.RenkoTest
17/06/2014 18:20:20   Starting "RenkoTest" strategy at 2014-06-17 18:20:20.241 GMT on the local computer
17/06/2014 18:19:20   Connected to d-ja-gva-101-135-154
17/06/2014 18:19:00   Reconnecting ...
17/06/2014 18:18:55   Reconnection pause: 5 seconds.


Strategy:
package singlejartest;

import java.io.*;
import java.util.*;

import com.dukascopy.api.util.DateUtils;
import com.dukascopy.api.*;
import com.dukascopy.api.feed.IFeedDescriptor;
import com.dukascopy.api.feed.IFeedListener;
import com.dukascopy.api.feed.util.RenkoFeedDescriptor;
import com.dukascopy.api.feed.IRenkoBarFeedListener;
import com.dukascopy.api.feed.IRenkoBar;
import com.dukascopy.api.feed.ITickBar;

public class RenkoTest implements IStrategy, IRenkoBarFeedListener, IFeedListener
{
    @Configurable("")
    public IFeedDescriptor renkoFeedDescriptor = new RenkoFeedDescriptor(Instrument.EURJPY, PriceRange.valueOf(3), OfferSide.ASK);

    private ITick tick;
    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();
        context.setSubscribedInstruments(java.util.Collections.singleton(renkoFeedDescriptor.getInstrument()), true);
        context.subscribeToFeed(renkoFeedDescriptor, this);
        context.subscribeToRenkoBarFeed(renkoFeedDescriptor.getInstrument(), renkoFeedDescriptor.getOfferSide(), renkoFeedDescriptor.getPriceRange(), this);
        LogToFile ("inizia");
    }

    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
    {
        if (!instrument.equals(renkoFeedDescriptor.getInstrument()))
        {
            return;
        }
        this.tick = tick;
        double value = 0.0;
        double volume = 0.0;
        if (renkoFeedDescriptor.getOfferSide() == OfferSide.ASK)
        {
            value = tick.getAsk();
            volume = tick.getAskVolume();
        }
        else
        {
            value = tick.getBid();
            volume = tick.getBidVolume();
        }
        ITickBar currentTickBar = history.getTickBar(renkoFeedDescriptor.getInstrument(), renkoFeedDescriptor.getOfferSide(), TickBarSize.valueOf(3), 0);
        IRenkoBar bar = history.getRenkoBar(renkoFeedDescriptor.getInstrument(), renkoFeedDescriptor.getOfferSide(), renkoFeedDescriptor.getPriceRange(), 0);
        console.getOut().println(DateUtils.format(ora()) +
                                 " tick: time: " + DateUtils.format(tick.getTime()) +
                                 " tick value: " + value +
                                 " tick volume: " + volume +
                                 " FEC: " + bar.getFormedElementsCount() +
                                 " incompleta endTime: " + DateUtils.format(bar.getEndTime()));
        LogToFile(DateUtils.format(ora()) +
                  " tick: time: " + DateUtils.format(tick.getTime()) +
                  " tick value: " + value +
                  " tick volume: " + volume +
                  " FEC: " + bar.getFormedElementsCount() +
                  " incompleta endTime: " + DateUtils.format(bar.getEndTime()));
    }

    @Override        //RENKO
    public void onBar(Instrument instrument, OfferSide offerSide, PriceRange brickSize, IRenkoBar bar)
    {
        if (instrument.equals(renkoFeedDescriptor.getInstrument()) &&
            offerSide.equals(renkoFeedDescriptor.getOfferSide()) &&
            brickSize.equals(renkoFeedDescriptor.getPriceRange()))
        {
            console.getOut().println(DateUtils.format(ora()) +
                                     " onBar: renko bar start: " + DateUtils.format(bar.getTime()) +
                                     " bar end: " + DateUtils.format(bar.getEndTime()) +
                                     " ticktime: " + DateUtils.format(tick.getTime()) +
                                     " open: " + bar.getOpen() +
                                     " high: " + bar.getHigh() +
                                     " low: " + bar.getLow() +
                                     " close: " + bar.getClose());
            LogToFile(DateUtils.format(ora()) +
                      " onBar: renko bar start: " + DateUtils.format(bar.getTime()) +
                      " bar end: " + DateUtils.format(bar.getEndTime()) +
                      " ticktime: " + DateUtils.format(tick.getTime()) +
                      " open: " + bar.getOpen() +
                      " high: " + bar.getHigh() +
                      " low: " + bar.getLow() +
                      " close: " + bar.getClose());
        }
    }

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

    }

    @Override
    public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData)
    {
        console.getOut().println(DateUtils.format(ora()) +
                                 " feedData: renko bar completed: " + feedData +
                                 " ticktime: " + DateUtils.format(tick.getTime()));
        LogToFile(DateUtils.format(ora()) +
                  " feedData: renko bar completed: " + feedData +
                  " ticktime: " + DateUtils.format(tick.getTime()));
//        console.getOut().println("feed description: " + feedDescriptor);
    }

    private long ora ()
    {
        long timeOra = 0;
        if (engine.getType() == IEngine.Type.TEST)
        {
            timeOra = tick.getTime();
        }
        else
        {
            timeOra = System.currentTimeMillis();
        }
        return timeOra;
    }

    private void LogToFile (String stringa)
    {
        if (stringa.length() == 0) return;

        String logFile = "renko_" + renkoFeedDescriptor.getInstrument().toString().replace("/","") + ".log";
        File file = new File(context.getFilesDir(), logFile);
        try
        {
            if (stringa == "inizia")
            {
                file.delete();
            }
            else
            {
                FileWriter fstream = new FileWriter(file.toString(), true);
                BufferedWriter out = new BufferedWriter(fstream);
                out.append(stringa + "\n");
                out.close();
            }
        }
        catch (IOException e)
        {
            e.printStackTrace (console.getErr());
        }
    }
}

Author:  Platform Support [ Wed 18 Jun, 2014, 07:39 ]
Post subject:  Re: Bad data in Renko feed

There is no in-progress bar anymore in Renko according to the new calculation system.
Change the code to:
IRenkoBar bar = history.getRenkoBar(renkoFeedDescriptor.getInstrument(), renkoFeedDescriptor.getOfferSide(), renkoFeedDescriptor.getPriceRange(), 1);

You need to get acquainted with Steve Nison's theory of Renko formation in order to understand why the in-progress bar is not possible anymore. It has been discussed here: viewtopic.php?f=85&t=50994&start=0

Author:  giorgio58 [ Wed 18 Jun, 2014, 08:25 ]
Post subject:  Re: Bad data in Renko feed

Same error with:

IRenkoBar bar = history.getRenkoBar(renkoFeedDescriptor.getInstrument(), renkoFeedDescriptor.getOfferSide(), renkoFeedDescriptor.getPriceRange(), 1);


It only works if I remove the line:

// IRenkoBar bar = history.getRenkoBar(renkoFeedDescriptor.getInstrument(), renkoFeedDescriptor.getOfferSide(), renkoFeedDescriptor.getPriceRange(), 1);

Is there any problem in history?

Author:  giorgio58 [ Wed 18 Jun, 2014, 09:55 ]
Post subject:  Re: Bad data in Renko feed

There is another problem,

with the attached procedure is not recorded and no event onBar or FeedData although there are 3 completed brics graphic from 06:51:33:203 to 08:37:25:760:

2014-06-18

1) 07:47:00.000 - 08:15:59.999
2) 08:16:00.000 - 08:24:59.999
3) 08:26:00.000 - 08:30:59.999
4) 08:31:00.000 - .....

As you can see from the attached file.

Attachments:
RenkoTest.java [6.51 KiB]
Downloaded 208 times
renko_EURJPY.log.zip [52.41 KiB]
Downloaded 176 times

Author:  tcsabina [ Wed 18 Jun, 2014, 12:57 ]
Post subject:  Re: Bad data in Renko feed

Quote:
Available on JForex4, version 4.08

How about the current JForex platform? Or if that is not going to be modified with this new Renko calculation, when do you plan the release the Live version if JForex 4?

Author:  jamesadk [ Fri 27 Jun, 2014, 12:50 ]
Post subject:  Re: Bad data in Renko feed

Hi,
Is there any update on the above?
Thanks
Quote:
It should be ready in few weeks on JForex4. Will implement in old JForex right after.

Author:  Platform Support [ Mon 30 Jun, 2014, 13:40 ]
Post subject:  Re: Bad data in Renko feed

The bug is fixed in 4.08.1 available on DEMO. There was an exception, that's why you didn't receive bars in his strategy.

However, the code you have provided shows that you do not understand renko sessions and renko creation points.
By default renko session is one minute and creation point is close price. It looks like you expect renkos on each tick, not after every minute (session) is finished. If you want to create a feed, which gets calculated on each tick, then you must provide a renko feed descriptor, where the renko session is set to Period.TICK.

In the sample provided below we corrected/simplified everything. The idea is still similar to the given one.

package renko_bug;

import com.dukascopy.api.Configurable;
import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.ITimedData;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.OfferSide;
import com.dukascopy.api.Period;
import com.dukascopy.api.PriceRange;
import com.dukascopy.api.feed.IFeedDescriptor;
import com.dukascopy.api.feed.IFeedListener;
import com.dukascopy.api.feed.util.RenkoFeedDescriptor;

@SuppressWarnings("deprecation")
public class RenkoTest implements IStrategy, IFeedListener {
   
   @Configurable("")
    public IFeedDescriptor renkoFeedDescriptor = new RenkoFeedDescriptor(Instrument.EURJPY, PriceRange.valueOf(3), OfferSide.ASK); //default renko session is 1min, creation point = close

    private IConsole console;
   
    public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
        context.setSubscribedInstruments(java.util.Collections.singleton(renkoFeedDescriptor.getInstrument()), true);
        context.subscribeToFeed(renkoFeedDescriptor, this);
    }

    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 {
       if (Period.ONE_MIN.equals(period) && Instrument.EURJPY.equals(instrument)){
          console.getOut().println("One min ask candle finished: " + askBar );          
       }
    }

    @Override
    public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) {
        console.getOut().println( " onFeedData: renko bar completed: " + feedData );
    }

}

Author:  Platform Support [ Mon 30 Jun, 2014, 13:45 ]
Post subject:  Re: Bad data in Renko feed

tcsabina wrote:
Quote:
Available on JForex4, version 4.08

How about the current JForex platform? Or if that is not going to be modified with this new Renko calculation, when do you plan the release the Live version if JForex 4?


We will start implementing this in old JForex as soon as you give a positive feedback ;)

Author:  giorgio58 [ Tue 01 Jul, 2014, 14:01 ]
Post subject:  Re: Bad data in Renko feed

Seems to be ok, only FEC is wrong.


01/07/2014 12:52:01 time: 2014-07-01 12:52:01:043 onFeedData: renko bar completed: StartTime: 2014-07-01 12:49:00.000 EndTime: 2014-07-01 12:51:59.999 O: 138.93 C: 138.9 H: 138.93 L: 138.9 V: 146.85 FEC: 1
01/07/2014 12:49:00 time: 2014-07-01 12:49:00:384 onFeedData: renko bar completed: StartTime: 2014-07-01 12:14:00.000 EndTime: 2014-07-01 12:48:59.999 O: 138.96 C: 138.93 H: 138.96 L: 138.93 V: 2711.89 FEC: 1
01/07/2014 12:14:00 time: 2014-07-01 12:14:00:186 onFeedData: renko bar completed: StartTime: 2014-07-01 11:54:00.000 EndTime: 2014-07-01 12:13:59.999 O: 138.96 C: 138.99 H: 138.99 L: 138.96 V: 1862.78 FEC: 1
01/07/2014 11:54:01 time: 2014-07-01 11:54:01:035 onFeedData: renko bar completed: StartTime: 2014-07-01 11:52:00.000 EndTime: 2014-07-01 11:53:59.999 O: 138.96 C: 138.93 H: 138.96 L: 138.93 V: 225.48 FEC: 1
01/07/2014 11:52:00 time: 2014-07-01 11:52:00:652 onFeedData: renko bar completed: StartTime: 2014-07-01 11:46:00.000 EndTime: 2014-07-01 11:51:59.999 O: 138.99 C: 138.96 H: 138.99 L: 138.96 V: 508.8 FEC: 1
01/07/2014 11:46:00 time: 2014-07-01 11:46:00:192 onFeedData: renko bar completed: StartTime: 2014-07-01 11:11:00.000 EndTime: 2014-07-01 11:45:59.999 O: 139.02 C: 138.99 H: 139.02 L: 138.99 V: 2462.13 FEC: 1
01/07/2014 11:11:00 time: 2014-07-01 11:11:00:303 onFeedData: renko bar completed: StartTime: 2014-07-01 10:46:00.000 EndTime: 2014-07-01 11:10:59.999 O: 139.05 C: 139.02 H: 139.05 L: 139.02 V: 1914.63 FEC: 1
01/07/2014 10:46:01 time: 2014-07-01 10:46:01:056 onFeedData: renko bar completed: StartTime: 2014-07-01 09:49:00.000 EndTime: 2014-07-01 10:45:59.999 O: 139.08 C: 139.05 H: 139.08 L: 139.05 V: 3790.91 FEC: 1

I await to the implementation on JForex 2 to backtesting

Thank you

Author:  Platform Support [ Tue 01 Jul, 2014, 14:31 ]
Post subject:  Re: Bad data in Renko feed

What is the session used here? Base period 1 week or Infinity?

Author:  giorgio58 [ Tue 01 Jul, 2014, 14:38 ]
Post subject:  Re: Bad data in Renko feed

Base period 1 week.

Author:  Platform Support [ Wed 02 Jul, 2014, 09:40 ]
Post subject:  Re: Bad data in Renko feed

FEC issue has been fixed. Will be deployed in next release in few weeks.

Author:  giorgio58 [ Mon 14 Jul, 2014, 19:19 ]
Post subject:  Re: Bad data in Renko feed

There is any news about the availability in JForex 2?

Author:  Platform Support [ Thu 17 Jul, 2014, 16:39 ]
Post subject:  Re: Bad data in Renko feed

Only one thing: we are working on this. ;)

  Page 2 of 5