Thanks for your post. The Help Guide is still a work in progress so the index page isn't indexed yet.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
writing all Trades to a file
Collapse
X
-
Accessing optimalisation results
Hi there,
How can I access the results of an 'Optimizer backtest', so that these can be further analysed in an statistical program?
Currently, I'm using the following for the export of individual trades:
Even though this code can be used for an Optimizer Backtest (by calculating these values for each optimizer run), that would not be very helpful given that the TradeCollection class doesn't provide an 'ParameterSetting' variable which can be used to discriminate between the various trades written to the .txt file. To illustrate what I mean, I'm looking for something like:Code:TradeCollection trades = Performance.AllTrades; foreach (Trade p in trades) { // accessing the traderesults through p. }
The variable with the strategy settings is important because this will enable me to use this as a factor and differentiate between the various variations of the optimized strategy.Code:StrategyCollection strategy = Performance.AllTrades; foreach (Strategy s in strategy) { // Accessing the results of the strategy variation, for example // for strategy "MA10/MA20", "MA10/15", etc. }
(Edit: To illustrate my point further, I added an image with the NinjaTrader output of the 'parameter length' and 'parameter name' variable(s) which I'm trying to access through C#.)
So, my question is:
- Is there an way to access the parameter values of the strategy being optimized?
- If that doesn't exist, is there a way to workaround this, so that I still can export the results of the optimized strategies?
Thanks in advance for any suggestions,
Regards,
Comment
-
Thanks for your comments Bertrand and Darckeen.
Perhaps it can be more simple than creating a base, here's what I have so far (which is good enough for my goal, namely to get the parameter values and name):
Which results in:Code:public void OutputOptimalisationData() { int length = StrategyData.Strategy.Indicators.Count; for (int i = 0; i < length; i++) { Print(StrategyData.Strategy.Indicators[i].ToString()); } foreach (Parameter i in Parameters) { Print("Name: " + i.Name.ToString() + " value: " + i.Value.ToString()); } Print("\n"); }
Regards,Code:EMA(MSFT (Daily),7) EMA(MSFT (Daily),15) Name: EmaKort value: 7 Name: EmaLang value: 15 EMA(MSFT (Daily),7) EMA(MSFT (Daily),16) Name: EmaKort value: 7 Name: EmaLang value: 16
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment