Announcement

Collapse
No announcement yet.

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X