Hi
I got a NullPointerException.There is no error on compilation.
I am running the code from Eclipse.
I only included 2 lines of simple code in onStart()
The rest of the interface is as default template.
However if i put the code only in onTick(), then this exception does not happen.
Please kindly advise. Thanks.
public class MrX implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
int i;
long time;
double closePrice;
SimpleDateFormat sdf= new SimpleDateFormat("dd:MM:yyyy");
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();
IBar prevbar=history.getBar(Instrument.EURUSD,Period.DAILY_SKIP_SUNDAY,OfferSide.BID,2);
time=prevbar.getTime();
}
//////////////////////////////////////CONSOLE MESSAGE///////////////////////////////////////////////////////
Strategy "MrX" is started at 2011-04-12 16:47:45.036 GMT on the local computer with no parameters
java.lang.NullPointerException @ singlejartest.MrX.onStart(MrX.java:38)
null: java.lang.NullPointerException
at singlejartest.MrX.onStart(MrX.java:38)
at com.dukascopy.api.impl.execution.s.call(Unknown Source)
at com.dukascopy.api.impl.connect.an.a(Unknown Source)
at com.dukascopy.api.impl.connect.v.call(Unknown Source)
at com.dukascopy.api.impl.connect.v.call(Unknown Source)
at com.dukascopy.api.impl.execution.i.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at com.dukascopy.api.impl.execution.e$a.f(Unknown Source)
at com.dukascopy.api.impl.execution.e$a.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2011-04-13 00:47:45.051 ERROR DCClientImpl$a - Exception thrown while running onStart method: null
java.lang.NullPointerException
at singlejartest.MrX.onStart(MrX.java:38)
at com.dukascopy.api.impl.execution.s.call(Unknown Source)
at com.dukascopy.api.impl.connect.an.a(Unknown Source)
at com.dukascopy.api.impl.connect.v.call(Unknown Source)
at com.dukascopy.api.impl.connect.v.call(Unknown Source)
at com.dukascopy.api.impl.execution.i.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at com.dukascopy.api.impl.execution.e$a.f(Unknown Source)
at com.dukascopy.api.impl.execution.e$a.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Stopping "MrX" strategy at 2011-04-12 16:47:45.052 GMT on the local computer