protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time) { ... WriteTradeExecutionToFile(execution, firstEntry); ... }
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!
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
NinjaTrader
Writing execution to file, when executing CloseStrategy()
Collapse
X
-
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:Tags: None
-
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); }
Note: GetOwnerStrategy() is not a documented/supported item, but you may find it useful through your testing.
We look forward to assisting.Attached FilesJimNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Conall, Today, 12:06 AM
|
0 responses
3 views
0 likes
|
Last Post
by Conall
Today, 12:06 AM
|
||
Started by proptradingshop, 03-21-2024, 09:50 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 12:02 AM | ||
Started by mly916, Yesterday, 09:48 PM
|
1 response
11 views
0 likes
|
Last Post Yesterday, 11:54 PM | ||
Started by Mikey_, Yesterday, 09:21 PM
|
0 responses
11 views
0 likes
|
Last Post
by Mikey_
Yesterday, 09:21 PM
|
||
Started by cre8able, Yesterday, 05:53 PM
|
3 responses
14 views
0 likes
|
Last Post
by cre8able
Yesterday, 09:20 PM
|
Comment