Following works fine when started inside JForex because then the charts and data is already initialized
/usr/lib/jvm/jre1.6.0_21/bin/javaws -J-Djnlp.client.username=name -J-Djnlp.client.password=pass -J-Djnlp.strategy.path="/home/name/JForex/Strategies/Line.jfx;" https://www.dukascopy.com/client/live/jclient/jforex.jnlp
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.*;
public class Line implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
private IHorizontalLineChartObject line = null;
private IChart chart;
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();
chart = context.getChart(Instrument.EURUSD);
long currBarTime = history.getStartTimeOfCurrentBar(Instrument.EURUSD, Period.DAILY);
java.util.List<IBar> bars = history.getBars(Instrument.EURUSD,
Period.DAILY,
OfferSide.BID,
history.getTimeForNBarsBack(Period.DAILY,
currBarTime,
10),
currBarTime);
IBar todaysBar = bars.get(bars.size()-1);
line = chart.getChartObjectFactory().createHorizontalLine("line", todaysBar.getLow());
chart.addToMainChart(line);
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}