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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X