Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need a little help with order filled code

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

    Need a little help with order filled code

    Hi, please excuse my lack of knowledge about coding matters.
    I'm trying to insert this code into a strategy to email me when an order is filled.

    protected override void OnExecution(IExecution execution)
    {
    if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
    {
    SendMail(@"[email protected]", @"NT8 Buy Action", @"Buy Order Placed");
    }
    }

    However when I compile I receive the following error message.

    The type or namespace name ='IExecution' could not be found (are you missing a using directive or an assembly reference?) CODE CS0246

    Can anyone advise me of what stupid thing I'm doing here thanks heaps.
    I found the code on another thread, so not sure if it works for NT8

    #2
    Hello Jimmyk,

    Thank you for the post.

    This code is for NinjaTrader 7, OnExecution() has been changed to OnExecutionUpdate() in NinjaTrader 8.

    In NinjaTrader 8, all order data can now be accessed in OnExecutionUpdate() instead of OnExecution().

    Here is the equivalent function with the send mail statement.

    Code:
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time){
        if(execution.Order != null && execution.Order.OrderState == OrderState.Filled){
            SendMail(@"[email protected]", @"NT8 Buy Action", @"Buy Order Placed");
        }
    }
    Below I have included publicly available links to the Execution class, OnExecutionUpdate(), SendMail(), and the code breaking changes for NinjaTrader 8.

    https://ninjatrader.com/support/help...?execution.htm - Execution class
    https://ninjatrader.com/support/help...tionupdate.htm - OnExecutionUpdate()
    https://ninjatrader.com/support/help.../?sendmail.htm -SendMail()

    Here is a full table of all code variances between NinjaTrader 7 and 8:



    Please let us know if we may be of any further assistance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    69 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    42 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    24 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    27 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    54 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X