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.

IChartObjectFactory NullPointerException on backtest
 Post subject: IChartObjectFactory NullPointerException on backtest Post rating: 0   New post Posted: Mon 14 Feb, 2011, 16:53 
User avatar

User rating: 5
Joined: Fri 02 Sep, 2011, 10:08
Posts: 157
Location: FranceFrance
Hi,

I'm using IChartObjectFactory to draw rectangles on the chart.

In "visual mode" everything is fine, but if I backtest in normal mode or through
the optimizer, I have a java.lang.NullPointerException.

I presume I have the same issue by running in Remote mode because my
strategy doesn't take any trade (because of the exception I think, but
I can't check this since we can't access the log yet).

I use the following code :

myChartObject = chart.getChartObjectFactory().createRectangle();
myChartObject.setTime(0, creationTime);
myChartObject.setTime(1, __time2);
myChartObject.setPrice(0, __price1);
myChartObject.setPrice(1, __price2);
myChartObject.setAttrColor(IChartObject.ATTR_COLOR.COLOR, __color);
chart.addToMainChart(myChartObject);



Did I do something wrong ? I have this issue since a long time so I use
a boolean to disable chart drawing when I'm not running in visual mode.
But this is just a manual "Turn around"...

Thanks


 
 Post subject: Re: IChartObjectFactory NullPointerException on backtest Post rating: 0   New post Posted: Wed 16 Feb, 2011, 09:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please make sure chart isn't null:
if (chart != null){
...
}

And for chart not to be null it has to be opened. When you use visual mode chart is opened automatically.


 

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