Hello,
I've found bug in createChannel method. When I use my alternative method and put 2nd channel point in place I've calculated myself, the top channel line draws in unexpected way.
Please see attached code and visualisations. Both visualisations should be identical because it is the same channel, but in case 2 the top line draws in random place.
Would you fix the issue?
Regards,
FXer
PS The example is from May 31st but I put long numbers instead of dates to simplify it.
Case 1:
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IChannelChartObject;
public class StrategyXXX implements IStrategy {
private IEngine engine;
private IContext context;
IChannelChartObject channel;
IChart chart;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.context = context;
chart = context.getChart(Instrument.EURUSD);
channel = chart.getChartObjectFactory().createChannel("channelLine",
1338437132050L, 1.23690, // 1st channel point
1338450545114L, 1.23870, // 2nd channel point
// 1338813066876L, 1.26416, // alternative 2nd channel point - the same channel!!!
1338449192426L, 1.24171); // 3rd channel point
chart.addToMainChart(channel);
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
if (chart.get("channelLine") != null) { chart.remove("channelLine"); } }
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}
Case 2, alternative method, 2nd point calculated:
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IChannelChartObject;
public class StrategyXXX implements IStrategy {
private IEngine engine;
private IContext context;
IChannelChartObject channel;
IChart chart;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.context = context;
chart = context.getChart(Instrument.EURUSD);
channel = chart.getChartObjectFactory().createChannel("channelLine",
1338437132050L, 1.23690, // 1st channel point
// 1338450545114L, 1.23870, // 2nd channel point
1338813066876L, 1.26416, // alternative 2nd channel point - the same channel!!!
1338449192426L, 1.24171); // 3rd channel point
chart.addToMainChart(channel);
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
if (chart.get("channelLine") != null) { chart.remove("channelLine"); } }
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}