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 rocketman7, Today, 09:41 AM
    2 responses
    4 views
    0 likes
    Last Post rocketman7  
    Started by traderqz, Today, 09:44 AM
    1 response
    4 views
    0 likes
    Last Post traderqz  
    Started by rocketman7, Today, 02:12 AM
    7 responses
    31 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by guillembm, Yesterday, 11:25 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by junkone, 04-21-2024, 07:17 AM
    10 responses
    150 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X