Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

NPException error
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=21&t=51727
Page 1 of 1

Author:  us_copiosus [ Wed 01 Oct, 2014, 20:14 ]
Post subject:  NPException error

Hi

I am getting the following error on three different strategies - all three did run cleaning in the past!

java.lang.Exception @ strategy-name.GetBars (...)

I have the following code..................

public List<IBar> GetBars()throws java.text.ParseException, JFException
{
long prevBarTime2 = myHistory.getPreviousBarStart(myPeriod,
myHistory.getLastTick(myInstrument).getTime());

List<IBar> bars = myHistory.getBars(myInstrument, myPeriod, OfferSide.BID,
com.dukascopy.api.Filter.WEEKENDS, 6, prevBarTime2, 0);

int last = bars.size() - 1;

return bars;
}

public double [][] IBarsToArray(List<IBar> inputBars)
{
double [][] ohlcvArray = new double[6][inputBars.size()];
for (int i = 0; i < inputBars.size(); i++){
ohlcvArray[0][i] = inputBars.get(i).getTime();
ohlcvArray[1][i] = inputBars.get(i).getOpen();
ohlcvArray[2][i] = inputBars.get(i).getHigh();
ohlcvArray[3][i] = inputBars.get(i).getLow();
ohlcvArray[4][i] = inputBars.get(i).getClose();
ohlcvArray[5][i] = inputBars.get(i).getVolume();

}
return ohlcvArray;

}

Any suggestions on how I track down this bug?

Bob M
Dunedin
New Zealand

Author:  tcsabina [ Fri 03 Oct, 2014, 13:28 ]
Post subject:  Re: NPException error

Hi,

Normally a line number is also shown for an exception. Do you see the line number?

Author:  us_copiosus [ Sat 04 Oct, 2014, 09:40 ]
Post subject:  Re: NPException error

The line number refers to this line

long prevBarTime2 = myHistory.getPreviousBarStart(myPeriod,
myHistory.getLastTick(myInstrument).getTime());

Bob M

Author:  tcsabina [ Sun 05 Oct, 2014, 19:30 ]
Post subject:  Re: NPException error

Without being too specific about your exact code, I can say that I've seen issues with some history.getXXXX functions when the Historical Tester was started on a weekend (when the market is closed). If you happen to run these strategies in the historical tester, maybe check what is the starting day of your tests. If it is a weekend, modify it for a weekday, and see if that solves the issue.

If this is irrelevant, I suggest to create a simplified strategy that replicates the issue. It will be much easier for Support as well, to pick the issue up with a strategy attached.

  Page 1 of 1