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 kinfxhk, 07-14-2026, 09:39 AM
      0 responses
      125 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      85 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      84 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X