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:	323
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 NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 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