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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    94 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    80 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    75 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Working...
    X