protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if (execution.Order.Name.StartsWith("EnterLong"))
{
if (orderState == OrderState.Filled || orderState == OrderState.PartFilled)
{
//long position open
}
}
else if (execution.Order.Name.StartsWith("ExitLong"))
{
if (orderState == OrderState.Filled || orderState == OrderState.PartFilled)
{
//long position closed
}
}
else if (execution.Order.Name.StartsWith("ExitLongLimit"))
{
if (orderState == OrderState.Accepted)
{
//ExitLongLimit accepted
}
else if (orderState == OrderState.Cancelled)
{
//ExtLongLimit cancelled e.g. CancelOrder()
}
else if (orderState == OrderState.Filled || orderState == OrderState.PartFilled)
{
//ExitLongLimit filled, long position closed
}
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnExecutionUpdate
Collapse
X
-
OnExecutionUpdate
could someone check that I have this right ..
I used the following order names e.g. EnterLong, ExitLong & ExitLongLimitCode:Last edited by delTik; 04-27-2016, 10:13 AM.Tags: None
-
Hello delTik,
I would not be able to say if this is correct as the code that places the entry orders is not included. The names you are looking for would need to match the signal names used for the order.
Using string.StartsWith is fine to use.
You can also use IOrders to match orders.
For the most part this looks fine.
The question is, when you test the code does it do what you are expecting?Chelsea B.NinjaTrader Customer Service
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
45 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
30 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
99 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
177 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
170 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Comment