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

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Tim-c, Today, 03:54 AM
    0 responses
    3 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Started by FrancisMorro, Today, 03:24 AM
    0 responses
    2 views
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,770 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    31 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    945 views
    0 likes
    Last Post spwizard  
    Working...
    X