Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Global Variables?

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

    Global Variables?

    Hello I am in a situation where I would like to share data between two of my indicators. For example I would like to use the value returned by indicator A to derive the value of indicator B. Is there a way to do this?

    In other words is there a centralized, thread-safe data store that can be written to/read from anywhere?

    #2
    Hello spiralhead,

    Global variables in C# can be used but are not supported. I'm not sure you will need them in this case. You can easily access plots from other indicators. If the value is not a plot, we have a sample available for accessing these values from other indicators:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hello. Thank you. Is there an example of how to access a plot as well?

      Comment


        #4
        Plots can be accessed by calling the indicator directly. The line below gets the most recent MACD average plot.

        MACD(12, 26, 9).Avg[0]

        The easiest way to get syntax for multi plot indicators is using the strategy wizard. You can select which plot you want from the GUI and then click view code option.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          The alternative approach to the sample indicator Ryan is pointing to is to use the UserDefinedMethods. You find the templetes both in "Strategy" and "Indicator". Don't know if that is thread save.

          Regards
          Ralph

          Comment


            #6
            Ninjatrader,
            I need to know if UserDefinedMethods and Startegies are thread safe.

            I'm running multiple strategies each of which call the same methods inside UserDefinedMethods.cs. In the methods, the below functions are called which are ment to refer to the the calling strategy.

            Will each strategy & method combo be in it's own seperate thread? Or will the UserDefinedMethods pass results back to a 'wrong' strategy?

            functions used ...

            Position.MarketPosition == MarketPosition.Short
            Position.AvgPrice
            Performance.AllTrades.TradesPerformance.Currency.A vgProfit
            DefaultQuantity
            and so on

            Comment


              #7
              Hi Sajosh,

              Yes, it is fine to use these properties in the user defined methods file. They will only relate to the strategy instance that calls them.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Hiya, is anyone know programms on simple stratgey on Ninja trader. Please email me.

                Comment


                  #9
                  superstar,

                  We have automated strategy development webinars every other tuesday at 5:30 PM EST. These webinars are free, live and interactive.

                  Please see a link to our webinar schedule here : http://www.ninjatrader.com/webinars

                  Additionally, we have some tutorials in our help guide, please find a link below.



                  If you have limited time or programming abilities, you could contact one of our NinjaScript consultants.



                  Please let us know if you require additional assistance.
                  Adam P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  646 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  367 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  107 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  569 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X