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 RideMe, 04-07-2024, 04:54 PM
    6 responses
    31 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    2 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,281 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X