Dukascopy
 
 
Wiki JStore Search Login

NullPointerException after compiling - redirected from community board.
 Post subject: NullPointerException after compiling - redirected from community board. Post rating: 0   New post Posted: Thu 09 Oct, 2014, 10:18 
User avatar

User rating: 0
Joined: Wed 16 Jul, 2014, 14:44
Posts: 21
Location: PolandPoland
Greetings,

[ and sorry for my english ]

i'm writing here because i have been redirected from community board with my issue.

I hope that pasting again my description of the problem here will not be punished, somehow.
I'm precisely describing the nature of issue below:

--------
I have a [propably trivial] 'issue' with running my strategy, which i won't be able to solve
myself easily, so very please - give me an 'complete, plain answer'. Without it, i'll propably
lost many hours on lurking on some java forums.

I've made strategy in visual jforex, and it does exactly what i wanted it to.
I've watched it running for time, that showed me, that every 'function' of my strategy is...
working like i expect it to. I was running it through 'visualjforex/compiler/run' and it just
worked.

So - i've compiled it, as strategy must be compiled in order to be used on live.
The very same strategy which worked before compiling, after compiling immediately returns

error:

java.lang.NullPointerException

which was not an issue at all when i was running strategy through 'visualjforex/compiler/run'.

I propably know 'where from' this error comes, i've read topics on that forum, which are more
or less about that error. Error is showing in exactly same kind of situations all the time,
which i'm going to describe.

My strategy simply does:

1. On the beginning, open position called 'BidStart'/'AskStart'

2. if one of those positions meets specified circumstances, than open new positions called

'BidNext/'AskNext'

3. If 'BidNext/'AskNext' fill time, or any other data connected to those positions meets

specified requirements, do... some next things.

And - this is exactly where 'NullPointerException' is showing up and stopping my system.
It shows there, where there is need for some 'BidNext/'AskNext' data, or in other words - data
from positions, that are not yet created at all.

As i've read, 'NullPointerException' means, that some variable is 'null'.

But in this scenario, in 'my strategy scenario', there is nothing wrong with the fact, that
there are null variables. This is not a 'mistake' from my part, i wanted system to check on
every candle for positions called 'BidNext/'AskNext' which have, for example, fill time x/y, or
profit-loss x/y. And as those 'BidNext/'AskNext' positions are not created 'on the beggining'
of strategy work, this is perfectly correct, that 'fill time', or 'profit/loss' of
'BidNext/'AskNext' positions are at some moments... null.

It should not be 'seen' as an error, and it isn't seen as error when i'm running the
exactly strategy through 'visualjforex/compiler/run'.


So what i'm very much asking:

- here i'm pasting full error message, and full 'code of block' which those error is reffering
to. All of error cases are very similar, all the difference between them is 'type of data' [
fill time, creation time, profit/loss, state ] that they are trying to extract from position,
that just isn't created yet at all.

Please, 'rewrite' this block, or any other part of sorce code which i've attached to this post, so it just does not stop my strategy when it meets some null variable.
Please 'rewrite' this block in fashion, that will make it behave exactly like it
behaves when i use 'visualjforex/compiler/run', i mean - when i run strategy before it is
compiled.

In 'non compiled run' scenario, if strategy is meeting 'if block' when there is field for
variable connected with position that is not created, it just assumes, correctly, that
'circumstances are not met' to follow the flow further - and strategy is going to the next
flow, without stopping and informing me on some errors.

Please rewrite the block or source, to behave exactly that.
I would also be very grateful if You could do this correction in a way, that i could reproduce in future, similar problems. I mean - if You could tell me where exactly to put what exactly code.


I also kindly ask, that You... not [ or at least - not only ] give me 'hints' or 'tips' about
Java language, i have absolute zero knowledge about programmimg and 'links' or some 'answers'
will not help me, so, please just write those few lines of 'ready code', so i could paste it
whenever i feel necessary and just fill it with correct variables, depending on situation.
I've made whole system work without bothering forumers much, so i hope i deserve such a favor
:)

All i ask is to some 'Java programmer' take a look at my strategy 'compiled source code', and showed me how to tell java... just not to stop when meeting a null variable.

If java ABSOLUTELY MUST stop when meeting null variable, let's tell the java:

if 'variable x' = null
than
assign 'value y' to variable null and continue with 'variable x'='value y'

It may be not 'professional coder approach', but i'm not trying this source code to be clean or perfect - i'd just like to make it work, and to know how to avoid such errors in future.

I also hope i've made myself very clear about the nature of issue and solution i need.



So, the full error message:
xxxxxxxxxxxxxx
14:06:50 java.lang.NullPointerException @ com.dukascopy.visualforex.nine99.test10.If_block_94

(test10.java:1021)
xxxxxxxxxxxxxx


and corresponding code:

private void If_block_94(Integer flow) {
long argument_1 = BidNext.getFillTime(); <<<<<<<<< this is the line 1021
double argument_2 = BestPosCreaTimeDBL;
if (argument_1< argument_2) {
}
else if (argument_1> argument_2) {
}
else if (argument_1== argument_2) {
If_block_95(flow);
}
}


My topic about this issue on community board is under adress [ may be as well deleted until now]:
viewtopic.php?f=199&t=51749

Thank You in advance for Your help,

kind regards


Attachments:
Amine2.java [42.84 KiB]
Downloaded 147 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: NullPointerException after compiling - redirected from community board. Post rating: 0   New post Posted: Thu 09 Oct, 2014, 11:32 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello!

This looks like a bug in Visual JForex. We've registered the issue for Visual JForex development team.


 
 Post subject: Re: NullPointerException after compiling - redirected from community board. Post rating: 0   New post Posted: Thu 09 Oct, 2014, 13:05 
User avatar

User rating: 0
Joined: Wed 16 Jul, 2014, 14:44
Posts: 21
Location: PolandPoland
Great, i'm glad to hear that.

I'm just thinking, that searching for the bug in whole 'visual jforex' and fixing it, and than testing it all back etc, must take a lot of time.
I hope i'm wrong about that.

But if i'm not - is there a option of giving me, before 'fixing bug in visual jforex', some temporary solution so i could just run my strategy?
I'm asking that question because i'm afraid that fixing that bug permanently in whole program may take Development Team even many weeks...

Thank You in advance for Your answer and time,
kind regards


 
 Post subject: Re: NullPointerException after compiling - redirected from community board. Post rating: 0   New post Posted: Thu 09 Oct, 2014, 13:54 
Visual JForex expert at Dukascopy
User avatar

User rating:
Joined: Mon 22 Apr, 2013, 11:30
Posts: 604
Location: UkraineUkraine
Greetings.

Actually it is not a bug. It is misunderstanding of how variables work.

You compare BidNext.Fill Time to BestPosCreaTimeDBL in IF 94 block.

Image

But BidNext variable is in empty (NULL) state. It can not be compared to anything. So platform returns Exception.
Position variable has to be assigned first, in other words it has to be used in Market or Pending block.
Just like you do with BidStart and AskStart variables.

Image


Attachments:
Picture 2.jpg [229.1 KiB]
Downloaded 339 times
Picture.jpg [78.72 KiB]
Downloaded 323 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: NullPointerException after compiling - redirected from community board. Post rating: 0   New post Posted: Sat 25 Oct, 2014, 12:45 
User avatar

User rating: 0
Joined: Wed 16 Jul, 2014, 14:44
Posts: 21
Location: PolandPoland
Thank You very much for Your help.

After assigning those values at the start of system, problem dissapeared.


 

Jump to:  

cron
  © 1998-2024 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