Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Writing execution to file, when executing CloseStrategy()

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

    Writing execution to file, when executing CloseStrategy()

    Hi, each time an order is executed, it is written to a file. unfortunately, the OnExecutionUpdate() method is no longer executed when CloseStrategy() is used. how can i have this last order execution also written to the file? does anyone have any ideas?

    Code:
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
       ...
       WriteTradeExecutionToFile(execution, firstEntry);
       ...
    }
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thanks for your post.

    The CloseStrategy() order wouldn't be seen with OnExecutionUpdate, but you could consider creating a listener AddOn/indicator that subscribes to account level Execution events.

    From the account level ExecutionUpdate event method, you can check the undocumented GetOwnerStrategy() method from the executing order to identify the owning strategy. This won't pass for the CloseStrategy order, but you can give the CloseStrategy order it's own signal name/order name so you can identify it in your listener AddOn. (You could pass the Strategy Name with the CloseStrategy call so the listener can identify and associate that order as you need.)

    Code:
    private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
    {
        if (e.Execution.Order.GetOwnerStrategy() != null)
            Print(e.Execution.Order.GetOwnerStrategy().ToStrin g());
        else if (e.Execution.Order.Name == "CloseStrategyOrder")
             Print(e.Execution.Order.Name);
    }
    Account.ExecutionUpdate - https://ninjatrader.com/support/help...tionupdate.htm

    Note: GetOwnerStrategy() is not a documented/supported item, but you may find it useful through your testing.

    We look forward to assisting.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    30 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    64 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X