So, what am I doing wrong?
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
Value[0] is throwing IndexOutOfRangeException.
Collapse
X
-
Value[0] is throwing IndexOutOfRangeException.
I'm trying to write my first Indicator. Its extremely simple and I'm following the code path from SMA but when I step into the code in VS the this.Value isn't initialized and thus this.Value[0] is throwing an exception. I don't see anywhere within SMA source code file where Value is being initialized and the base class NinjaScriptBase defines the property as returning null.
So, what am I doing wrong? -
Originally posted by Kabua View PostI'm trying to write my first Indicator. Its extremely simple and I'm following the code path from SMA but when I step into the code in VS the this.Value isn't initialized and thus this.Value[0] is throwing an exception. I don't see anywhere within SMA source code file where Value is being initialized and the base class NinjaScriptBase defines the property as returning null.
So, what am I doing wrong?
-
Welcome to the forums Kabua!
It sounds like the indicator is missing AddPlot().
I suggest using the New Indicator Wizard (NinjaScript Editor > Indicators folder > Right Click > New Indicator) as it can conveniently add all the code necessary for plots. I have also included a link to our AddPlot() documentation which can be referenced for creating working plots.
AddPlot() - https://ninjatrader.com/support/help...s/?addplot.htm
As koganam mentions, attaching the code can help us to understand exactly what you are running into.
I look forward to being of further assistance.JimNinjaTrader Customer Service
Comment
-
Yes, me bad. I wasn't sure what was the difference between AddPlot and AddLine when I went through the wizard. Therefore, I choose AddLine but it appears what I really wanted was AddPlot, once I changed the code to AddPlot the Value property was properly initialized. Thanks.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
2 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
3 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
33 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,239 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
6 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment