How can i check if the last closed trade has been closed by SL or TP?.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Check if last closed trade reached SL or TP
Collapse
X
-
Hello,
One way would be to use the OnExecution override to check which order had last filled.
Based on which order was filled you could get its signal name, or FromEntrySignal name to determine which order was filled and which order this was a stop or target for.
I look forward to being of further assistance.
-
Hello vibarco,
Here is some example code that may help here:
In this example your output window would show something like:Code:protected override void OnExecution(IExecution execution) { if (execution.Name == "Stop loss") Print(string.Format("{0} - Stop loss was filled", execution.Time)); if (execution.Name == "Profit target") Print(string.Format("{0} - Profit Target was filled", execution.Time)); }
8/17/2015 5:55:00 AM - Profit Target was filled
8/17/2015 7:00:00 AM - Stop loss was filled
8/17/2015 7:27:00 AM - Stop loss was filled
8/17/2015 7:53:00 AM - Profit Target was filled
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
110 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
156 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
74 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
125 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
79 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment