Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 martin70, 03-24-2023, 04:58 AM
      14 responses
      105 views
      0 likes
      Last Post martin70  
      Started by TraderBCL, Today, 04:38 AM
      0 responses
      2 views
      0 likes
      Last Post TraderBCL  
      Started by Radano, 06-10-2021, 01:40 AM
      19 responses
      606 views
      0 likes
      Last Post Radano
      by Radano
       
      Started by KenneGaray, Today, 03:48 AM
      0 responses
      4 views
      0 likes
      Last Post KenneGaray  
      Started by thanajo, 05-04-2021, 02:11 AM
      4 responses
      470 views
      0 likes
      Last Post tradingnasdaqprueba  
      Working...
      X