I'm getting this error, I don't understand I have it defined this way double MAD = 3; what did I do wrong? And I'm not getting any trades generated.
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
mad
Collapse
X
-
You need to refer to it as the exact case used in RelativeVigorIndex which is "Signal" not "sIGNAL". That may not be the only problem - the compilation problem you posted does not have anything do with a local variable MAD or with trading - it's not referring to the series output of the nested indicator by its correct name.
-
Hello RMin101,
Thanks for your post.
As QuantKey_Bruce noted, the error message in the screenshot you shared is regarding the RelativeVigorIndex() in your script, not the MAD = 3.
How exactly are you defining RelativeVigorIndex() in your script?
See this help guide page for information about using the RelativeVigorIndex() method and sample code: https://ninjatrader.com/support/help...igor_index.htm
Brandon H.NinjaTrader Customer Service
Comment
-
Hello RM,
Thanks for that information.
This error indicates that at some point in your script the MAD property is evaluating to a value of 0 which is outside the valid range.
Debugging prints would need to be added to the script to understand where in the script the MAD property is returning a value of 0 outside of the valid range.
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121Brandon H.NinjaTrader Customer Service
Comment
-
If you are not setting MAD to zero somewhere in your code, then in OnStateChange in State == State.SetDefault you need to set MAD to a default value such as 1.
You are not giving it a default, yet you are insisting it is only valid from 1 to int.maxvalue. Ints default to 0, and that is invalid per the range you have specified, yet you do not provide a default that is valid.
Comment
-
Hello RM,
Thanks for your note.
Are you setting the MAD variable to a default value in State.SetDefaults?
If not, the MAD variable could be evaluating to 0 in the script since a default value is not being assigned to it in State.SetDefaults as QuantKey_Bruce mentioned.
Have you added debugging prints to your script to confirm that the MAD variable is not evaluating to a value of 0 in your script?
If not, debugging prints would need to be added to the script to confirm how the MAD variable is evaluating. Add prints to the script that print out the variable value to confirm how your logic is behaving.
Brandon H.NinjaTrader Customer Service
Comment
-
Hello RM,
Thanks for your post.
This error indicates that somewhere in your script the HL variable is evaluating to a value of 0 which is outside the valid range.
Debugging prints should be added to the script to confirm how the variable is evaluating in the script.
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
That said, instead of creating the variable in State.SetDefaults, you could create a class-level variable and then assign a value to the variable in State.SetDefaults.
Something you could do is create a few user-defined inputs and variables on the Inputs and Variables screen of the Strategy Builder and then click the 'View code' button to see the generated syntax used to create those inputs and variables and assign a default value to them.
Strategy Builder Inputs and Variables screen: https://ninjatrader.com/support/help...ariablesScreen
And, see this help guide page about creating user-defined inputs: https://ninjatrader.com/support/help...d_input_pa.htmBrandon H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pibrew, Today, 06:37 AM
|
0 responses
1 view
0 likes
|
Last Post
by pibrew
Today, 06:37 AM
|
||
Started by rbeckmann05, Yesterday, 06:48 PM
|
1 response
12 views
0 likes
|
Last Post
by bltdavid
Today, 05:43 AM
|
||
Started by llanqui, Today, 03:53 AM
|
0 responses
6 views
0 likes
|
Last Post
by llanqui
Today, 03:53 AM
|
||
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
11 views
0 likes
|
Last Post Today, 12:38 AM | ||
Started by AaronKoRn, Yesterday, 09:49 PM
|
0 responses
15 views
0 likes
|
Last Post
by AaronKoRn
Yesterday, 09:49 PM
|
Comment