Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    50 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    10 responses
    397 views
    1 like
    Last Post beobast
    by beobast
     
    Started by lorem, Yesterday, 09:18 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by WHICKED, Today, 12:56 PM
    2 responses
    15 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Felix Reichert, Today, 02:12 PM
    0 responses
    4 views
    0 likes
    Last Post Felix Reichert  
    Working...
    X