Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Object Reference not set to an instance of an Object. Bars == Null
Collapse
X
-
Object Reference not set to an instance of an Object. Bars == Null
I am getting the Object Reference not set to an instance of an Object error if I use Bars.IsFirstBarOfSession. I don't understand how this is possible since I am doing a check to see if Bars == null just before the exeption gets thrown. Also, the exception is getting thrown many hundreds of bars into the script so obviously bars was not null at some point and then turned null? Take a look at this screenshot:
Tags: None
-
Hello swcooke, thanks for your post.
There must be some aspect of your script that's causing this. When I run a contrived test IsFirstBarOfSession works for me. If you strip out code that is not needed to detect IsFirstBarOfSession does it return true or false in this instance?
Chris L.NinjaTrader Customer Service
-
Hi, swcooke.
Try to check the State value when error happened.
Probably, exception happened in another part of program and script start disposing, and that moment you may receive "null reference" error in any line, referring NT objects .Last edited by fx.practic; 03-27-2020, 12:29 AM.
Comment
-
I meant just this:
Just try to put State variable in watch window.
I guess, it would be State.Finalized
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
57 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
9 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment