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

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 WHICKED, Today, 12:45 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post WHICKED
                  by WHICKED
                   
                  Started by GussJ, 03-04-2020, 03:11 PM
                  15 responses
                  3,276 views
                  0 likes
                  Last Post xiinteractive  
                  Started by Tim-c, Today, 02:10 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by Taddypole, Today, 02:47 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post Taddypole  
                  Started by chbruno, 04-24-2024, 04:10 PM
                  4 responses
                  51 views
                  0 likes
                  Last Post chbruno
                  by chbruno
                   
                  Working...
                  X