• 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

Exception on OnBarUpdate for DataSeries

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

    Exception on OnBarUpdate for DataSeries

    Hi,

    I know this has been covered before, but I can't find a thread that has this covered for my situation. Sorry if this should be something really basic.

    I am working on an indicator, which uses several DataSeries objects.

    I have declared it as private. eg:

    Code:
            #region Variables
    			private DataSeries probUp;
    	#endregion
    I am initializing in Initialize():

    Code:
            protected override void Initialize()
            {
    			probUp = new DataSeries(this);
            }
    And using in OnBarUpdate()

    Code:
            protected override void OnBarUpdate()
            {
    				probUp[0] = 0;
            }
    But for some frustrating reason, I am getting a null reference exception relating to this last statement (actually using the probUp field). I have stared at the code for an hour or two, and can't figure it out. It seems to be fine with my similar IntSeries fields. What am I missing?

    I have tried using properties, not using properties, etc. It seems like it is not being initialized in the Initialize() method... Which is counter-intuitive, since it's right there!

    Thanks!

    #2
    What happens when you use

    probUp.set (0)

    ?

    See the help for dataseries. .And it also takes you to a sample file example.

    Comment


      #3
      I have the same problem--the reference was the first thing I looked at.

      Comment


        #4
        I am looking a little more closely in VS debugger, and I see the indicator reference is set to null for my DataSeries fields, but not for my IntSeries fields... Not sure, but maybe there is some problem with the initialization line...

        Comment


          #5
          Tracing more, it's some problem with the value getting wiped out through my accessors between initialize and OnBarUpdate.

          Anything stand out immediately?

          Code:
                  public DataSeries ProbUp
                  {
                      get { return probUp; }
                      set { probUp = value; }
                  }
          Edit: Seems to be something to do with the internals of how NS is using DataSeries.

          For some reason, the set accessor is being called automatically somewhere between Initialize and OnBarUpdate, but the call stack just says external code. If I set the field as public and drop the accessors, I don't see the exception anymore for this field.

          Hopefully with this info someone can point me in the right direction--I'd rather keep it abstracted as much as possible, though it probably doesn't actually matter at all for this.
          Last edited by Lavafang; 11-26-2014, 10:34 PM.

          Comment


            #6
            Lavafang, if you want to setup a series and expose this non plot associated series then for external script access (through a public property) then we would suggest following this example closely - http://www.ninjatrader.com/support/f...ead.php?t=4991

            The documented .Set for pushing a value in would be preferred.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Will do. Thanks.

              First glance looks like it's the same as what I have, except without the public set accessor method.

              Cheers.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rontronimous, Today, 06:12 PM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by Vinhasa, Today, 03:15 PM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by 1001111, Today, 03:03 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Tyler  
              Started by Seedbird, Today, 03:06 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_BrendanC  
              Started by mtamaku, Today, 02:46 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Kate  
              Working...
              X