Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

creating an IVerticalLineChartObject
 Post subject: creating an IVerticalLineChartObject Post rating: 0   New post Posted: Wed 31 Aug, 2011, 09:01 
User avatar

User rating: 6
Joined: Thu 19 May, 2011, 11:14
Posts: 235
Location: South Africa,
I'm trying to draw a vertical line according to IChart wiki (https://www.dukascopy.com/wiki/index.php?title=IChart), but am getting this exception:
08:11:36 java.lang.NoSuchMethodException: com.dukascopy.charts.drawings.VLineChartObject.<init>(java.lang.String, long, double) @ jforex.ColorTest.onTick(ColorTest.java:37)

public void onTick(Instrument instrument, ITick tick) throws JFException {
        IChart chart = context.getChart(Instrument.EURUSD);
        double price1 = (tick.getAsk() + tick.getBid()) / 2;
        IVerticalLineChartObject vLine = chart.getChartObjectFactory().createVerticalLine("vLine", // line 37
            tick.getTime(), price1
        );
        chart.addToMainChart(vLine);         
}


 
 Post subject: Re: creating an IVerticalLineChartObject Post rating: 0   New post Posted: Wed 31 Aug, 2011, 14:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The given examples in wiki are compatible to JForex API version 2.6.43, for earlier versions please use empty chart object constructors and thereafter set the price, time and other values to the newly created object. For VLINE use:
double price1 = (tick.getAsk() + tick.getBid()) / 2;
IVerticalLineChartObject vLine = chart.getChartObjectFactory().createVerticalLine();
vLine.setPrice(0, price1);
vLine.setTime(0, tick.getTime());
chart.addToMainChart(vLine);


 
 Post subject: Re: creating an IVerticalLineChartObject Post rating: 0   New post Posted: Thu 01 Sep, 2011, 11:18 
User avatar

User rating: 6
Joined: Thu 19 May, 2011, 11:14
Posts: 235
Location: South Africa,
Thank you. Is there a way to specify what the object's key should be?


 
 Post subject: Re: creating an IVerticalLineChartObject Post rating: 0   New post Posted: Thu 01 Sep, 2011, 12:15 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Unfortunately, not, you can just retrieve the key of an already created IChartObject.


 

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