Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Optimization Fitnesses
Collapse
X
-
Optimization Fitnesses
From within the above, it is possible to find out how many of the trades were exited via limit orders vs market ?Tags: None
-
Hello spottysallrite,
Thank you for your note.
You may get this information from a specific trade object using an index value for the TradeCollection being accessed. For example, building on the following example from the help guide that accesses the first and last trade in the strategy, we can also print out the order type for the exit of those trades:
The following links are relevant:Code:// Accesses the first/last trade in the strategy (oldest trade is at index 0) // and prints out the order type for the exit order if (SystemPerformance.AllTrades.Count > 1) { Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1]; Trade firstTrade = SystemPerformance.AllTrades[0]; Print("The last trade exit order type was " + lastTrade.Exit.Order.OrderType); Print("The first trade exit order type was " + firstTrade.Exit.Order.OrderType); }- https://ninjatrader.com/support/help...collection.htm
- https://ninjatrader.com/support/help.../nt8/trade.htm
- Exit is an execution object representing the exit, then we can get the Order.OrderType from that execution object
- https://ninjatrader.com/support/help.../execution.htm
- https://ninjatrader.com/support/help.../nt8/order.htm
When considering Optimization Fitness scripts, you could calculate the number of market exits for example using the following logic in OnCalculatePerformanceValue():
You could do something similar for limit orders or even make a ratio of limit order exits vs. market order exits depending on your needs.Code:protected override void OnCalculatePerformanceValue(StrategyBase strategy) { int marketExits = 0; if (strategy.SystemPerformance.AllTrades.Count > 1) { for (int x = 0; x < strategy.SystemPerformance.AllTrades.Count; x++) { if (strategy.SystemPerformance.AllTrades[x].Exit.Order.OrderType == OrderType.Market) marketExits++; } Value = marketExits; } }
Please let us know if we may be of further assistance.
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
44 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment