Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          561 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          325 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X