Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Queue: Object reference not set to an instance of an object.

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

    Queue: Object reference not set to an instance of an object.

    Hi,

    This may not be NT issue, but I am just asking if anyone has seen this error before.

    Thanks!


    Error on calling 'OnBarUpdate' method for indicator 'Myindicator' on bar 55: Object reference not set to an instance of an object.

    Code snippet:



    #region Variables
    // Wizard generated variables
    ....
    private Queue deltaVol;
    ....
    protected override void Initialize()
    {
    Queue<double> deltaVol = new Queue<double>();

    }

    And, the error is when the code is at this line:


    deltaVol.Enqueue( (double) Math.Abs(VolSell - VolBuy) );

    #2
    Originally posted by ssg10 View Post
    Hi,

    This may not be NT issue, but I am just asking if anyone has seen this error before.

    Thanks!


    Error on calling 'OnBarUpdate' method for indicator 'Myindicator' on bar 55: Object reference not set to an instance of an object.

    Code snippet:



    #region Variables
    // Wizard generated variables
    ....
    private Queue deltaVol;
    ....
    protected override void Initialize()
    {
    Queue<double> deltaVol = new Queue<double>();

    }

    And, the error is when the code is at this line:


    deltaVol.Enqueue( (double) Math.Abs(VolSell - VolBuy) );
    Your code looks like you have redefined deltaVol, giving it local scope. Try removing the declaration semantics in the Inititalize() method.

    Comment


      #3
      thanks.

      looks like the problem is with

      Queue<double> deltaVol = new Queue<double>();

      changed it to this fixed the problem:


      deltaVol = new Queue();

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      89 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X