Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question About Fetching Order Value

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

    Question About Fetching Order Value

    Hello Ninjatrader staff,

    What is the most efficient way to get the market value (not quantity) of a resting order such as a Buy Limit and Print out this value?
    When I use Print(S1.LimitPrice) I am getting this error in the Log tab "Error on calling 'OnBarUpdate' method on bar 5610: Object reference not set to an instance of an object".

    Thank you in advance for your reply!
    Last edited by GLFX005; 12-17-2020, 09:30 AM.

    #2
    Hello GLFX005, thanks for writing in.

    It looks like you have an order object reference that is null at the time you access the LimitPrice property. Check that the order is not null before accessing it, and make sure it's being set to an order before doing this as well.

    S1 = ExitLongLimit(...);

    if(S1 != null)
    {
    Print(S1.LimitPrice);
    }

    Alternatively, you can capture the limit price within the OnOrderUpdate method once it's submitted (in the working or accepted state):

    https://ninjatrader.com/support/help...rderupdate.htm

    Another alternative would be looping through the Account.Orders collection:
    https://ninjatrader.com/support/help...rs_account.htm

    Please let me know if you have any questions on this material.

    Comment


      #3
      Thank you Chris, that solved the issue!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      45 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      31 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X