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=51749Thank You in advance for Your help,
kind regards