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 cmoran13, 04-16-2026, 01:02 PM
          0 responses
          37 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          23 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          162 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          98 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          152 views
          2 likes
          Last Post CaptainJack  
          Working...
          X