Thank you
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Accessing the Optimization Context
Collapse
X
-
Accessing the Optimization Context
Is it possible to access the Optimization Context from within an Optimizing Strategy. I need to record some metadata related to the optimization, I was hoping to stick this in the notes field, or alternatively capture a known ID from the optimization context that would let me reference data that I could store externally.
Thank youTags: None
-
Hello kevinenergy,
You can save the results grids, which would be the easiest way.
On the results grid you want to save, right-click select > Export...
You can also save the parameters and performance metrics information by writing these to file. You might choose to make copies of existing scripts and add in the writing to file part.
Below are links to the help guide on these scripts.
https://ninjatrader.com/support/help...ce_metrics.htm
https://ninjatrader.com/support/help...ric_values.htm
https://ninjatrader.com/support/help...ness_value.htm
And a link to an example that demonstrates using StreamWriter to write to file.
https://ninjatrader.com/support/help...o_write_to.htm
For an instance ID you might create a public variable within the strategy and assign this a guuid in State.DataLoaded.
https://ninjatrader.com/support/foru...288#post726288
Then access that property from the strategy object provided to the OnCalculatePerformanceValue() method of the optimization fitness.
Attached is an example OptimizationFitness that calls values from a custom PerformanceMetric and also uses the strategy object.Chelsea B.NinjaTrader Customer Service
-
Hey Chelsea, thanks for pointing me in the right direction and for the example files and links. I was able to figure out how to do what I needed using these! Much appreciated!
Comment
-
Hi @NinjaTrader_ChelseaB
Most of links from your previous message no work, please could you update ti? I am interest in these:
You can also save the parameters and performance metrics information by writing these to file. You might choose to make copies of existing scripts and add in the writing to file part.
Below are links to the help guide on these scripts.
https://ninjatrader.com/support/help...ce_metrics.htm
https://ninjatrader.com/support/help...ric_values.htm
https://ninjatrader.com/support/help...ness_value.htm
Regards.
Comment
-
Hi @NinjaTrader_ChelseaB
Many thanks, now that is working,
Another question. Is there any example to get results grid in excel of the optimization by coding instead use the example below?
You can save the results grids, which would be the easiest way.
On the results grid you want to save, right-click select > Export...
https://ninjatrader.com/support/help...data_grids.htm
Regards.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
637 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
366 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
107 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
569 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
571 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment