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

ExecutionPrice - OrderPrice

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

    ExecutionPrice - OrderPrice

    Hello,

    from the NT-samples I know how I can get the Execution Price (in OnExecution with "exprice=execution.Order.AverageFillPrice) but I can´t find how I can get the "Order Price" before it is executed. (not in the sampleOnOrderUpdate nor in another sample). I need the value of a working short or long entrylimit.

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thank you for your post.

    The limit price of an order can be retrieved using Order.LimitPrice:

    Code:
    private Order entryOrder = null;
    
    protected override void OnBarUpdate()
    {
      if (entryOrder == null && Close[0] > Open[0])
          EnterLong("myEntryOrder");
    }
    
    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
      // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
      // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately        after submitting
      if (order.Name == "myEntryOrder")
          entryOrder = order;
    
      if (entryOrder != null && entryOrder == order)
      {
          Print(order.LimitPrice);
          if (order.OrderState == OrderState.Filled)
              entryOrder = null;
      }
    }
    If you assign the order to a variable, as we've done in the example above, you can then access that during OnBarUpdate using the variable - just make sure to check that it's not null before printing:

    Code:
            protected override void OnBarUpdate()
            {
                // other code omitted
    
                if(entryOrder != null)
                {
                    Print(entryOrder.LimitPrice);
                }
            }
    Here's a link to our help guide on the Order object:



    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by LiamTwine, Today, 08:10 AM
    0 responses
    0 views
    0 likes
    Last Post LiamTwine  
    Started by Balage0922, Today, 07:38 AM
    0 responses
    5 views
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    19 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    6 views
    0 likes
    Last Post Creamers  
    Working...
    X