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
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.JesseNinjaTrader Customer Service
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.You can find more information about OnStateChange here: https://ninjatrader.com/support/help...=onstatechange
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; } }
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); }
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kujista, Today, 05:44 AM
|
0 responses
1 view
0 likes
|
Last Post
by kujista
Today, 05:44 AM
|
||
Started by ZenCortexCLICK, Today, 04:58 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 04:58 AM | ||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
172 responses
2,281 views
0 likes
|
Last Post
by sidlercom80
Today, 04:40 AM
|
||
Started by Irukandji, Yesterday, 02:53 AM
|
2 responses
18 views
0 likes
|
Last Post
by Irukandji
Today, 03:55 AM
|
||
Started by adeelshahzad, Today, 03:54 AM
|
0 responses
8 views
0 likes
|
Last Post
by adeelshahzad
Today, 03:54 AM
|
Comment