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

Static Variables

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

    Static Variables

    Hi

    This is really a question for community members with C# knowledge.

    I use a static dictionary to hold various levels and can access this successfully across charts etc. However it only works for real time data.

    I really would like to be able to access the data across charts but also for historical data.

    Is there a way to do this / a thread that I have missed?

    thanks in advance..

    #2
    Hello I_Quant,

    How are are you current accessing the values?
    JCNinjaTrader Customer Service

    Comment


      #3
      I have this sequence.

      Indicator (A) that does nothing but setup the static dictionary as follows

      static Dictionary <string, double> dict = new Dictionary <string, double>();

      The get and set are exposed through the properties...as follows (not all the code)

      #region Properties
      [Browsable(false)]
      [Description("Get Dictionary Value")]
      public double getDict(string key)
      {
      this uses TryGetValue to access the dictionary with the key and
      returns the result

      dict.TryGetValue(mpkey, out result)
      }

      [Browsable(false)]
      [Description("Set Dictionary Value")]
      public bool setDict(string key, double val)
      {
      dict[key] = val;
      return true;
      ]

      then Indicator (B) sets the values like this

      IndicatorA().setDict("key", value);

      then

      Indicator (C) reads the values like this


      value = IndicatorA().getDict(key);

      As I say this seems to work fine for real time data, but I would like (as a first step) for
      the last values set to be able to be read by Indicator C (once the data goes "historic" eg at the end of the session), and ultimately would like a whole
      series of values based on prior historical data to be readable across charts etc.

      Comment


        #4
        Hello I_Quant,

        Thanks for that snippet.

        Using the Dictionary is unsupported so I would not be able to say what to expect, but with that said have you tried using a Try Catch block for your getDict() method to see if it is returning an error or the actual value historically?
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi

          This is really a question for community members with C# knowledge.

          I use a static dictionary to hold various levels and can access this successfully across charts etc. However it only works for real time data.

          I really would like to be able to access the data across charts but also for historical data.

          Is there a way to do this / a thread that I have missed?

          thanks in advance..

          I hope you don't mind me restating my original question as I knew that it was aimed at the C# help community here rather than Ninja staff per se.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rocketman7, Today, 09:41 AM
          3 responses
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by traderqz, Today, 09:44 AM
          2 responses
          4 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by stafe, 04-15-2024, 08:34 PM
          8 responses
          40 views
          0 likes
          Last Post stafe
          by stafe
           
          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  
          Working...
          X