Thanks!
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
Conversion error - accessing an index with a value that is invalid
Collapse
X
-
Conversion error - accessing an index with a value that is invalid
I'm trying to convert the 310 indicator from NT7 to NT8. Oddly enough, I don't get this same error in NT7. I understand what it means, in that when the indicator is first called there aren't enough bars to calculate it, but I'm not sure how to fix it. I'm attaching the NT7 and NT8 (converted but not working) versions. Can someone take a look at this and tell me how to fix it?
Thanks!Tags: None
-
Hello,
Thank you for the post.
I wanted to check if we are getting the same error, you noted that the error you are seeing is related to the amount of bars. I am seeing the following error, is this the same as what you are seeing?
'LBR310': Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.
If so, Object reference not set to an instance of an object just means that some object is being used while it is null. If this is the same error I can further review, otherwise if this is not the same error can you post the error you are seeing?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Originally posted by NinjaTrader_Jesse View PostHello,
Thank you for the post.
I wanted to check if we are getting the same error, you noted that the error you are seeing is related to the amount of bars. I am seeing the following error, is this the same as what you are seeing?
'LBR310': Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.
If so, Object reference not set to an instance of an object just means that some object is being used while it is null. If this is the same error I can further review, otherwise if this is not the same error can you post the error you are seeing?
I look forward to being of further assistance.
Comment
-
Hello sobertradingpartner,
Thank you for confirming this.
This indicates that there is a variable being called that has a null value.
Besure that you check for null with any nullable type.
For example:
private string MyVariable;
if (MyVariable != null && MyVariable == "Hello")
{
// execute code
}
This condition would not cause an error even though MyVariable is null but would not trigger.Chelsea B.NinjaTrader Customer Service
Comment
-
Index error appearing
Thank you for that. I've checked through the code and thre are no null values. When I add it to a chart now, the indicator area is blank. The Log says the following:
"Indicator 'LBR310': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
There are twenty days of bar values on the chart so I'm not sure where the problem is.
Comment
-
Closing price
I seem to have tracked down the error by using "Print()" statements. Adding this line on OnBarUpdate - Print("Close equals " + Close[0] + " at " + Time[0]); showed I was only getting the Price of the first bar since the beginning of the session, not the current bar price. On a 5 minute 6J chart at 5:58pm I got Close equals 0.008518 at 12/18/2016 3:05:00pm. That tells me it only processed the first bar of the open.
Using Print() again I found that the values of 'Close' and 'High' all resolve to Ninjatrader.Ninjascript.PriceSeries
This is followed by the error I mentioned above.Last edited by sobertradingpartner; 12-22-2016, 08:05 PM. Reason: more testing revealed more of the problem
Comment
-
Hello,
There is an NT8 version of the LBR310 in the dowloads section: http://ninjatrader.com/support/forum...hp?&linkid=823
Comment
-
Thanks
By looking at the already done conversion, I can see where I went wrong, mainly in the State configurations. I no longer need help with this, thanks everyone!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by inanazsocial, Today, 01:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by inanazsocial
Today, 01:15 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
22 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
||
Started by guillembm, Yesterday, 11:25 AM
|
2 responses
9 views
0 likes
|
Last Post
by guillembm
Yesterday, 11:58 PM
|
||
Started by junkone, 04-21-2024, 07:17 AM
|
9 responses
71 views
0 likes
|
Last Post
by jeronymite
Yesterday, 11:51 PM
|
Comment