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

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.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chris, that solved the issue!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      3 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      238 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      384 views
      1 like
      Last Post Gavini
      by Gavini
       
      Started by oviejo, Today, 12:28 AM
      0 responses
      4 views
      0 likes
      Last Post oviejo
      by oviejo
       
      Started by pechtri, 06-22-2023, 02:31 AM
      10 responses
      125 views
      0 likes
      Last Post Leeroy_Jenkins  
      Working...
      X