Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Can't use closing price during market replay
Collapse
X
-
Can't use closing price during market replay
I'm currently developing a strategy and I'm trying to use the 1 tick time frame to reconstruct candles. Whenever I try to get the closing price with Close[1], I get the error "Error on calling 'OnBarUpdate' method on bar ____: Object reference not set to an instance of an object." But it's fine when I use Close[0] except for the fact that it returns the opening price of the next candle instead of the closing price of the candle that just closed (wouldn't be a problem except for the fact that they aren't the same prices). Is there a reason as to why Close[1] doesn't work for market replay?Tags: None
-
Hello,
Thank you for your post.
Most likely this is coming from somewhere else in your script. In my testing, I can access Close[1] in Market Replay. Please see the attached test script. Are you still seeing the same error when using the test script?
Object reference not set to an instance of an object indicates that there is a null value in a variable being used in your script.
I recommend you debug the script to narrow now exactly which line your code is hitting this error at.
You can use prints, place a print every few lines with a new number: Print("1"); etc. That will help you see where the script gets in execution when you hit the error. Once you know what line throws the error its much easier to debug. After you have confirmed which line is throwing the error, you can add another print to then check which variable or object is null.
Attached Files
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
62 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
37 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|
||
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
166 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
101 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
162 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|

Comment