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.

Drawing ShortLine
 Post subject: Drawing ShortLine Post rating: 0   New post Posted: Tue 06 Sep, 2011, 06:14 

User rating: 0
Joined: Tue 06 Sep, 2011, 06:12
Posts: 5
Location: DE
Hi,

can someone tell me how to draw a shortline with the latest API? I tried with

chart.getChartObjectFactory().createShortLine("shortLine", firstBarTime, max, firstBarTime+15000, max);

but that throws an illegal argument exception.

Thanks,
Andreas


 
 Post subject: Re: Drawing ShortLine Post rating: 0   New post Posted: Tue 06 Sep, 2011, 11:16 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Your given factory method is compatible both with JForex API versions 2.6.38 and 2.6.43. If it is illegal argument exception then it is rather because of the parameters you pass to the method, not the API, consider the following example:
package charts.test;

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

public class ShortLine 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);
      long firstBarTime = history.getBarStart(chart.getSelectedPeriod(), tick.getTime());
      double max = tick.getBid();
      
      IShortLineChartObject line = chart.getChartObjectFactory().createShortLine("shortLine", firstBarTime, max, firstBarTime+15000, max);
      chart.addToMainChart(line);   
   }
   @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 {}

}


 

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