Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I add aditional Variables

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

    How do I add aditional Variables

    Can I add more than the variable1 - variable0 to a strategy? I am not using the wizard and need more variables.

    How do I use the bool? When I set the private bool "name" = true, I can't put a statement in a condition or action it give me error. Can you give me an example of its use?

    Thanks
    Ken

    #2
    Hello Ken,

    Thank you for your post.

    You can create however many variables you need. Are you asking how to create variables?

    The bool would be checked like the following:
    Code:
    if(myBool)
    // True
    if(!myBool)
    // False
    Or you could do the following:
    Code:
    if(myBool == true)
    // True
    if(myBool == false)
    // False

    Comment


      #3
      Correct how do i create additinal variables lke variable1 - variable0, lets say I want an additional 10 named:
      Variable11
      Variable12
      Variable13...

      Comment


        #4
        Hello kelliot,

        Thanks for your post.

        You can create and declare your variables in the #Region variables section. Here is an example of each common (there are a few more) type, the variable's name is in bold for your convienience:

        #region Variables

        private int zoneStrength = 5; // Creates an integer variable and assigns it the default/initial value of 5
        private bool useMtf = true; // Creates a bool variable and assigns it True
        private Color supColor = Color.DarkGray; // Create a color variable assigns it darkgray
        private Font textFont = new Font("Arial", 8); // creates a Font set called textFont
        private double upperLine,lowerLine,currAtr; // creates three double variables with null values initially
        private string val; // Create a string variable

        #endregion

        Please let us know if we can be of further assistance.

        Comment


          #5
          Where are Variable0 through variable9 set? I dont see them to use them as an example

          So in the region i would use the following
          Private int variable11 = 0
          Private int variable12 = 0

          I want to ue them with numeric values or set something like
          Variable11 = 1
          Variable12 = close[0] + stoploss

          Comment


            #6
            Hello kelliot,

            Thanks for your post.

            Sorry for any confusion, I wanted to give you a view of different variable types (int, double, bool, etc) and where the names were shown in bold could easily have been named variable11, variable12, etc.

            In your example, with variable12, would generate an error because you have declared variable12 as an integer and the expression Close[0] + stoploss would resolve to a double so it is important to understand what kind of variable you need to declare. Here is a link to the help guide that covers declaring variables http://www.ninjatrader.com/support/h...sic_syntax.htm

            Please let me know if I can be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X