Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3611 cant remove chart object
 Post subject: JFOREX-3611 cant remove chart object Post rating: 0   New post Posted: Fri 16 Mar, 2012, 10:04 

User rating: 0
Joined: Mon 23 May, 2011, 10:55
Posts: 9
Location: Netherlands,
Why do I get an
The method remove(String) in the type IChart is not applicable for the
arguments (IShortLineChartObject)
when trying to remove a chart object?

package jforex;

import java.util.*;

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

public class StrategyTest implements IStrategy {
 private IEngine engine;
private IConsole console;
private IHistory history;
 private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;

   private IShortLineChartObject askLine; // askLine line
 public void onStart(IContext context) throws JFException {
 this.engine = context.getEngine();
this.console = context.getConsole();
 this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
 this.userInterface = context.getUserInterface();
       IChart chart = context.getChart(Instrument.EURUSD);
       if (chart != null){
           askLine = chart.getChartObjectFactory().createShortLine();

       }
}

public void onAccount(IAccount account) throws JFException {
 }

public void onMessage(IMessage message) throws JFException {
 }

public void onStop() throws JFException {
       IChart chart = context.getChart(Instrument.EURUSD);
       try {
           chart.remove(askLine);
       } catch (Exception e)
       {}
}

 public void onTick(Instrument instrument, ITick tick) throws JFException {
       if ( instrument == Instrument.EURUSD )
       {
           IChart chart = context.getChart(Instrument.EURUSD);
           if (chart != null){
           long period = chart.getSelectedPeriod().getInterval();
           if ( period == -1)
           {
               period = 2000;
           }
           askLine.setPrice(0, tick.getAsk());
           askLine.setPrice(1, tick.getAsk());
           askLine.setTime(0, (long) (tick.getTime()));
           askLine.setTime(1, (long) (tick.getTime() + period));
           }
       }
}
   public void onBar(Instrument instrument, Period period, IBar askBar,
IBar bidBar) throws JFException {
   }
}


 
 Post subject: Re: JFOREX-3611 cant remove chart object Post rating: 0   New post Posted: Mon 19 Mar, 2012, 12:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You also need to plot the object on the chart, by using IChart.addToMainChart. See:
https://www.dukascopy.com/wiki/#Create_a ... rt_objects


 

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