Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Detect "exit on close" event
Collapse
X
-
Hello,
You could see when the ExitOnClose order is submitted or executed by using the OnOrderUpdate and OnExecution event methods to find with an order of that name for example:
If you have any further questions please let us know.Code:protected override void OnOrderUpdate(IOrder order) { if(order.OrderState == OrderState.PendingSubmit) if (order.Name == "Exit On Close") //DoSomething } protected override void OnExecution(IExecution execution) { if(execution.Name == "Exit On Close") //DoSomething }Cody B.NinjaTrader Customer Service
-
Detect ExitOnClose
Hi, I have a strategy in NT7 where ExitOnClose = true; when ExitOnClose is triggered, I need to change the value of an IOrder.
According to the post below, I tried the two following:, both do not work in backtesting:
protected override void OnOrderUpdate(IOrder order)
{
if (order.Name == "Exit On Close")
EnterLong = null;
}
and also:
protected override void OnExecution(IExecution execution)
{
if(execution.Name == "Exit On Close")
EnterLong = null;
}
I've also tried to change the name to "ExitOnClose" but without success. Could you help me to understand how to activate OnExecution (or OnOrderUpdate eventually) when ExitOnClose is triggered? Thanks in advance, Martin.
Comment
-
Hello marticora,
Using the attached strategy, and a custom session template I set up to end one minute into the future, I was able to obtain the following output, emphasis mine
I recommend copying and pasting the above string into your code. If you would prefer typing it in, it looks like the E in exit is capitalized, and the o and c in on and close, respectively, are lowercase. Each word is separated by a space.Order: 'Order='d7bf382479cf41b9b7147cff10b08559/Sim101' Name='Exit on close' State=Filled Instrument='ES 09-16' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=1 Fill price=2174.5 Token='d7bf382479cf41b9b7147cff10b08559' Gtd='1/1/0001 12:00:00 AM''
Order name: 'Exit on close'
--------------------------------------------------------------------------------
execution: 'Execution='c8f9731e94604e4ba2a97b45d473d3b9' Instrument='ES 09-16' Account='Sim101' Name='Exit on close' Exchange=Default Price=2174.5 Quantity=1 Market position=Short Commission=0 Order='d7bf382479cf41b9b7147cff10b08559' Time='8/30/2016 11:11:30 AM''
execution name: 'Exit on close'
execution order name: 'Exit on close'
Please let us know if there are any other ways we can help.Attached FilesJessica P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
77 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
45 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
27 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
63 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment