Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3596 Issues with ChartObjectFactory (API)
 Post subject: JFOREX-3596 Issues with ChartObjectFactory (API) Post rating: 0   New post Posted: Wed 07 Mar, 2012, 14:37 
User avatar

User rating: 5
Joined: Fri 02 Sep, 2011, 10:08
Posts: 157
Location: FranceFrance
Hello,

I'm updating my strategies on the new Demo2.14.28.1/API 2.6.60.1 so I have no surprise when the Live platform will be online.

I have some troubles with chartobjects drawn from strategies. Please see the following list :


1 - Can't figure out how to create a chartOject with an object Key without using deprecated methods, see exemple :

The following code works, but createRayLine(objectKey, params) is deprecated :
IRayLineChartObject line = chart.getChartObjectFactory().createRayLine(objectKey,
                    lastTick.getTime(), lastTick.getBid() + 0.005,
                    firstPoint.getTime(), lastTick.getBid());
                    chart.addToMainChart(line);


Using the non deprecated method with an objectKey doesn't draw anything :
Quote:
IRayLineChartObject line = chart.getChartObjectFactory().createRayLine(objectKey);
line.setTime(0, lastTick.getTime());
line.setPrice(0, lastTick.getBid() + 0.005);
line.setTime(1, firstPoint.getTime());
line.setPrice(1, lastTick.getBid());


It seems entering an object key does not work for all chartObjects.

3 - How to lock a chartObject on the chart ? (previously we used addToMainChartUnlocked() to lock or not the object)

It would be nice to have an updated documentation on the chartObject wiki.


Thanks
Best regards


 
 Post subject: Re: Issues with ChartObjectFactory (API) Post rating: 0   New post Posted: Wed 07 Mar, 2012, 15:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
nicofr0707 wrote:
1 - Can't figure out how to create a chartOject with an object Key without using deprecated methods, see exemple :
We were not able to reproduce this. We tested with the following strategy:
package charts.test;

import java.awt.Color;
import java.util.UUID;

import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IRayLineChartObject;

public class RayLine implements IStrategy {

    private IChart chart;
    private IHistory history;
   
    @Override
    public void onStart(IContext context) throws JFException {
        this.chart = context.getChart(Instrument.EURUSD);
        this.history = context.getHistory();
        ITick tick = history.getLastTick(Instrument.EURUSD);   

        double price1 = (tick.getAsk() + tick.getBid()) / 2;
        IRayLineChartObject line1 = chart.getChartObjectFactory().createRayLine();
        line1.setPrice(0, price1);
        line1.setTime(0, tick.getTime());
        line1.setPrice(1, price1 - 0.0010);
        //5 bars ahead
        line1.setTime(1, tick.getTime() - chart.getSelectedPeriod().getInterval() * 5);
        line1.setColor(Color.BLUE);
        chart.addToMainChart(line1);
       
        //use the same coordinates, but change the style
        IRayLineChartObject line2 = chart.getChartObjectFactory().createRayLine(UUID.randomUUID().toString(),
                line1.getTime(0), line1.getPrice(0),
                line1.getTime(1), line1.getPrice(1));
        line2.setOpacity(0.2f);
        line2.setColor(Color.RED);
        line2.setLineWidth(10);
        chart.addToMainChart(line2);
       
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }

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

    @Override
    public void onMessage(IMessage message) throws JFException {}

    @Override
    public void onAccount(IAccount account) throws JFException {}

    @Override
    public void onStop() throws JFException {}

}


Attachment:
RayLine.java [1.79 KiB]
Downloaded 364 times

nicofr0707 wrote:
3 - How to lock a chartObject on the chart ? (previously we used addToMainChartUnlocked() to lock or not the object)
There is no more division in unlocked or locked objects.
nicofr0707 wrote:
It would be nice to have an updated documentation on the chartObject wiki.
Please elaborate on what additional information you would like to find in the JForex wiki? Regarding deprecated methods in object catalog - they have not been replaced, since they are due to be reintroduced but with a more informative signature, e.g.:
instead of:
IRectangleChartObject createRectangle(Object... params)
there will be:
IRectangleChartObject createRectangle(String key, long time1, double price1, long time2, double price2)


 
 Post subject: Re: Issues with ChartObjectFactory (API) Post rating: 0   New post Posted: Wed 07 Mar, 2012, 16:42 
User avatar

User rating: 5
Joined: Fri 02 Sep, 2011, 10:08
Posts: 157
Location: FranceFrance
Thanks for the reponse.

Quote:
//use the same coordinates, but change the style
IRayLineChartObject line2 = chart.getChartObjectFactory().createRayLine(UUID.randomUUID().toString(),
line1.getTime(0), line1.getPrice(0),
line1.getTime(1), line1.getPrice(1));
line2.setOpacity(0.2f);
line2.setColor(Color.RED);
line2.setLineWidth(10);
chart.addToMainChart(line2);


In Netbeans this is marked as deprecated, isn't it ? : public IRayLineChartObject createRayLine(Object... params)

In the javadoc you see the following syntax to use with a key (I didn't saw this in your exemple). public IRayLineChartObject createRayLine(String key)


And what about my second question about objects not keeping their position after a reboot of JForex (it seems it has been deleted from my message) ? This is for me a more concerning issue. Should I post my screenshot again so you can see ?

Thanks


 
 Post subject: Re: JFOREX-3596 Issues with ChartObjectFactory (API) Post rating: 0   New post Posted: Thu 08 Mar, 2012, 10:17 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
nicofr0707 wrote:
In Netbeans this is marked as deprecated, isn't it ? : public IRayLineChartObject createRayLine(Object... params)
Yes it is, we included it in the example to show that both methods do the same thing.
nicofr0707 wrote:
In the javadoc you see the following syntax to use with a key (I didn't saw this in your exemple). public IRayLineChartObject createRayLine(String key)
This bug has been registered.
nicofr0707 wrote:
And what about my second question about objects not keeping their position after a reboot of JForex (it seems it has been deleted from my message) ? This is for me a more concerning issue. Should I post my screenshot again so you can see ?
This part of your post been moved to
viewtopic.php?f=85&t=46704 since it is related to the desktop platform, not API.


 
 Post subject: Re: JFOREX-3596 Issues with ChartObjectFactory (API) Post rating: 0   New post Posted: Fri 09 Mar, 2012, 18:27 
User avatar

User rating: 5
Joined: Fri 02 Sep, 2011, 10:08
Posts: 157
Location: FranceFrance
ok thanks


 

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