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
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,610 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    16 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X