Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding To Position

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

    #16
    Thanks for the reply. What you're running into is variable scope. To overcome this, we recommend declaring all variables in the variables region, so that they're available any place you need in your script.

    #region Variables
    private bool LongSet = false;
    private double LongPrice;
    #endregion

    When you want to use these variables in your code, you don't need to place the type (double, bool) in front.

    LongSet = true;
    LongPrice = GetCurrentAsk();
    Last edited by NinjaTrader_RyanM1; 09-02-2011, 01:21 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      I noticed in the last two posts that the declaration of the variable is "longSet" and the usage of the variable is "LongSet" (different cases/spellings). Since C# is case sensitive, could this be the issue?

      Comment


        #18
        dojidubbs,

        private variables are lower case.

        Public variables are upper case.

        When declaring your variables, they first should to be declared as private. When using the variables in your script we recommend using them as Public variables.

        We do not have any educational resources on the differences between using these variables - if you'd like clarification on these you should check MSDN or other C# educational resources.
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        649 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        576 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X