• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 tecmisc1, Today, 09:57 AM
          0 responses
          2 views
          0 likes
          Last Post tecmisc1  
          Started by mbesha, Today, 09:26 AM
          0 responses
          1 view
          0 likes
          Last Post mbesha
          by mbesha
           
          Started by Brillo, Today, 08:58 AM
          0 responses
          6 views
          0 likes
          Last Post Brillo
          by Brillo
           
          Started by avrege, Today, 01:48 AM
          2 responses
          13 views
          0 likes
          Last Post avrege
          by avrege
           
          Started by markbb10, Today, 07:14 AM
          0 responses
          7 views
          0 likes
          Last Post markbb10  
          Working...
          X