Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

General Variables

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

    General Variables

    Hello

    Does general variables exists on NT7? By general parameters I mean variables which are shared by all running strategies. For example, in case my strategy is running on two charts, a change in the variable on the strategy on the first chart will be effecting the value on the strategy on the second chart as well

    Thanks

    #2
    Hello,

    Thank you for the question.

    In NinjaTrader there is not a default "global" variable per say, One way to do this would be to use the UserDefinedMethods file.

    If you click Tools -> Edit NinjaScript -> Strategy you will find the file UserDefinedMethods


    Inside this file you could do something like the following:

    Code:
     partial class Strategy
        {
    		public static int MyTestValue;
        }
    Now from Strategy A, you could set the value simply by calling it by name:


    Code:
    MyTestValue = 100;

    From Strategy B reading the data is the same:

    Code:
    Print(MyTestValue);
    Because the variable Is marked static it persists between instances of the strategies.

    You can find more on static here: https://msdn.microsoft.com/en-us/library/79b3xss3.aspx



    Please let me know if I may be of further assistance.
    Last edited by NinjaTrader_Jesse; 02-26-2016, 10:00 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 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
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X