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

How to share var values among multiple instances of an indicator?

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

    How to share var values among multiple instances of an indicator?

    As asked in the title, is it possible to share variables between multiple instances of an indicator?

    Without adding additional data series into an indicator, I'm wondering if/how to share data among multiple instances of an indicator.

    For example, if one chart sets the value of a bool to true, can that bool remain true even if ninjascript is reloaded on any of the charts that are using said indicator?

    would declaring the bool as static suffice, or would the class in which the bool belongs also need to be static? (assuming this approach would even work)

    is there a better or more efficient way of going about doing this?

    thanks in advance!

    #2
    Hi there TG,

    Thanks for opening the thread.

    You're brainstorming in the right direction. We have advised to create an AddOn with partial classes for indicators and strategies with static methods for methods that are to be shared, and to create static variables within the AddOn for variables that you wish to persist between NinjaScripts.

    Attached is a copy of the demonstration.

    If there is anything else I can do to assist, please let me know.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      excellent!

      Thank you Jim!

      Comment


        #4
        Jim, thanks for sharing the sample code.

        In the Addon TestShareData I tried to include a simple Dictionary<string, string>.
        And then in the Indicator TestShareDataIndicator I tried to add data to the Dictionary.
        So far I have failed miserably at getting this to work. Nothing but errors and NT freeze ups.

        Can you toss me a bone on how to created the Dictionary in public static class ShareData and then in Indicator how to access the Dictionary.

        Thanks.

        Comment


          #5
          Hello TAJTrades,

          I appreciate you reaching out to me. This is not something I would be able to provide further direction for, however.

          This question is more related to general C# than it is with the NinjaScript built on top of it. While we try to be helpful by providing sample code that can demonstrate a certain concept with NinjaScript, we cannot commit to creating samples for our clients that demonstrates any concept in general. We have this policy as we are a small team and are not equipped to handle such inquiries for all of our clients.

          Thanks for your understanding. If you would like to get connected with a member of our Business Development team who can then connect you with NinjaScript Consultants who would be able to further assist you in development, I would be happy to have someone reach out.

          If there is anything else I could do to assist, please let me know.
          JimNinjaTrader Customer Service

          Comment


            #6
            Jim,
            I understand. However you may want to pass on these comments to Ray:

            If I am unable to create charting tools in NT the probability of me getting a subscription to Kinetic Data is slightly below zero. The probability of me opening a Ninja Brokerage Account is even less. And before you mention the possibility of NT Vendors I will say that the probability of uninstalling NT8 before getting a vendor subscription is slightly above 100%.

            I know this is not your decision, that you are following directives from above. But the top management should be made aware of this. I can also state that I am not alone in this opinion.

            So until I can complete the coding, if ever, I shall keep my accounts with IRT and Stage5.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by funk10101, Today, 09:43 PM
            0 responses
            6 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Yesterday, 08:51 AM
            8 responses
            44 views
            0 likes
            Last Post bill2023  
            Started by yertle, Today, 08:38 AM
            6 responses
            26 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            24 views
            0 likes
            Last Post algospoke  
            Working...
            X