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.

NullPointerException in onStart()
 Post subject: NullPointerException in onStart() Post rating: 0   New post Posted: Tue 12 Apr, 2011, 17:53 

User rating: -
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


 
 Post subject: Re: NullPointerException in onStart() Post rating: 0   New post Posted: Thu 14 Apr, 2011, 09:29 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
This is a known issue and a fix will be available in the next release.


 

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