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!
See more
See less

Partner 728x90

Collapse

mad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    mad

    HI

    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.
    Attached Files

    #2
    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.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      hmm ok, I'll check but I'm getting the same message with all of my inputs.

      Comment


        #4
        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


          #5
          ok here is the correct screen shot, thank you!
          Attached Files

          Comment


            #6
            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#post791121
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Mad is just an input with a value of 3, it's never set to 0 or any match done on it, and the same with all my other inputs. I used the strategy builder and just built a very simple entry with a simple cross over and I got the same error.

              Comment


                #8
                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.
                Bruce DeVault
                QuantKey Trading Vendor Services
                NinjaTrader Ecosystem Vendor - QuantKey

                Comment


                  #9
                  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


                    #10
                    Hi

                    I am setting the values in the onStateChange

                    protected override void OnStateChange()
                    {
                    if (State == State.SetDefaults)
                    {

                    double HL = 37;

                    }​
                    Attached Files

                    Comment


                      #11
                      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.htm
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        You can't do "double HL = 37" in State.Defaults - that's creating a local variable that will be chucked as soon as the method OnStateChange exits.

                        What you want to do is simply "HL = 37" there so you are setting the field variable in this instance of your indicator class.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by pibrew, Today, 06:37 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post pibrew
                        by pibrew
                         
                        Started by rbeckmann05, Yesterday, 06:48 PM
                        1 response
                        12 views
                        0 likes
                        Last Post bltdavid  
                        Started by llanqui, Today, 03:53 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post llanqui
                        by llanqui
                         
                        Started by burtoninlondon, Today, 12:38 AM
                        0 responses
                        11 views
                        0 likes
                        Last Post burtoninlondon  
                        Started by AaronKoRn, Yesterday, 09:49 PM
                        0 responses
                        15 views
                        0 likes
                        Last Post AaronKoRn  
                        Working...
                        X