Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecutionUpdate Get Entry Price

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

    OnExecutionUpdate Get Entry Price

    Hello,

    I am trying to get the entry price of my positions to store as a double to use elsewhere in my code. This is what I have right now:

    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
    breakevenprice = execution.Order.AverageFillPrice;
    }


    This code is doing as intended and giving me the average fill price. The issue is on candles where the execution is a profit target or a stop loss, or a profit target and an entry. See image:Click image for larger version

Name:	Screen Shot 2022-02-02 at 4.11.00 AM.png
Views:	341
Size:	99.8 KB
ID:	1187993

    With the code I am currently using, the double breakeven price will calculate as the profit target or stop loss when that is the execution type, and on candles with both entries and stop losses will trigger as either. How can I tell OnExecutionUpdate to change breakevenprice only when the execution type is long or short? And not profit targets, stop losses, or exits on session closes?

    Thanks​

    #2
    Hello thereyoflite1,

    Thank you for your post.

    Are you keeping track of your entry orders using a variable like illustrated in SampleOnOrderUpdate here:

    https://ninjatrader.com/support/help...and_onexec.htm

    If you are, you could check to see if the Order associated with the Execution is an entry order and update the double breakeven price accordingly so it would not change if the order is another order type like a stop or an exit on session close order.

    Please let us know if we may be of further assistance to you.

    Comment


      #3

      Thank you,

      I was able to resolve this by setting breakevenprice equal to averagefill when the entry is "mystring" in the OnOrderUpdate section.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      32 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      195 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      358 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      278 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X