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 FrancisMorro, Today, 03:24 AM
    0 responses
    1 view
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,770 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    31 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    944 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    11 views
    0 likes
    Last Post Max238
    by Max238
     
    Working...
    X