Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Compile Errors
Collapse
X
-
Compile Errors
I have converted this indicator from NT7 to NT8 and cannot get it to compile error free. The compile error I'm getting is "'int' does not contain a definition for 'SetDefaults' and no extension method 'SetDefaults' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)". I have tried finding the problem with no luck. Any help would be appreciated.Tags: None
-
Hello mlarocco,
Are you seeing any errors when opening the indicators menu listed in the control center -> Logs tab?
It looks like you are trying to copy the "Initialize" override from NT7 one for one however a lot of that syntax has changed with NT8. There is no longer a single starting point or Initialize, instead there is a state system composed of multiple different states.
Before continuing with your conversion, I would strongly suggest looking at the SMA indicators code to see how the default structure of a script should look and try to model your script after that structure. You can also see the SampleMultiTimeframe strategy for an example of creating a multi series script and its structure. I see you are using properties which do not belong in State.SetDefaults but belong in other states later in your scripts initialization process so you will likely need to go line by line and make sure the code belongs where you have it.
You can also find samples for most NinjaScript methods and properties in the help guide such as AddDataSeries: https://ninjatrader.com/support/help...ghtsub=adddata
This needs to go in State.Configure but you have it in State.Defaults.
You can find more information about OnStateChange here: https://ninjatrader.com/support/helpGuides/nt8/en-us/onstatechange.htm?zoom_highlightsub=onstatechange
I would also suggest reviewing the code breaking changes guide: https://ninjatrader.com/support/help...ng_changes.htm
I look forward to being of further assistance.Last edited by NinjaTrader_Jesse; 05-21-2019, 11:42 AM.
Comment
-
Hello mlarocco,
Yes in this case the error states the problem, you are calling AddDataSeries in the wrong location. For this part of the question you can find samples of the correct syntax in the items I had mentioned or:
You can also find samples for most NinjaScript methods and properties in the help guide such as AddDataSeries: https://ninjatrader.com/support/help...ghtsub=adddata
This needs to go in State.Configure but you have it in State.Defaults.In this situation comparing what you have made against something which is known to work (SMA or SampleMultiTimeframe) can help to highlight the problems. The code you have created in the Initialize() method will need to be modified to look like the other indicators/samples you see in NT8. Right now you are calling AddDataSeires in the state SetDefaults:You can find more information about OnStateChange here: https://ninjatrader.com/support/help...=onstatechange
You would instead need to make your code look like the help guide or other scripts show and have mutliple states:Code:protected override void OnStateChange() { switch (State) { case State.SetDefaults: Name = "ETOpeningRange_NT8"; Description = "Opening Range indicator"; [B] Initialize(); // <---- running all your code for State.SetDefaults [/B] break; } }
I look forward to being of further assistance.Code:if (State == State.SetDefaults) { //some default properties will be configured here } else if (State == State.Configure) { // add data series goes here, State.Configure AddDataSeries("AAPL", BarsPeriodType.Minute, 5); }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
597 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
343 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
556 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
555 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment