Dukascopy
 
 
Wiki JStore Search Login

createChannel bug
 Post subject: createChannel bug Post rating: 0   New post Posted: Mon 04 Jun, 2012, 14:04 

User rating: 1
Joined: Tue 24 Apr, 2012, 13:41
Posts: 39
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 {
    }
}


Attachments:
File comment: case 2 - wrong channel visualisation
2.png [41.46 KiB]
Downloaded 388 times
File comment: case 1 - correct channel visualisation
1.png [39.87 KiB]
Downloaded 374 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 

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