The change is apparently enough that my tests against selected enum values is not working during an optimization, even though I can see that the optimizer itself is iterating through the checkbox values. Basically, I think I just need to know how to reference the optimizer checkbox values, but I do not know how to do this. Any help would be greatly appreciated!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Testing enums values work as expected in standard backtest, but not in optimization
Collapse
X
-
Testing enums values work as expected in standard backtest, but not in optimization
Hi, I have an enum which I can successfully test the value selected in a standard backtest. However, when I run an optimization things do not work as expect. I am 99% sure this is due to my not knowing how to compensate for the change enum selectors undergo when an optimization is chosen. (this change is visually obvious - for a "Standard" Backtest an enum selector is in form of a dropdown style menu, whereas for an 'Optimization' the selector for an enum automatically changes to checkbox values for each enum option)
The change is apparently enough that my tests against selected enum values is not working during an optimization, even though I can see that the optimizer itself is iterating through the checkbox values. Basically, I think I just need to know how to reference the optimizer checkbox values, but I do not know how to do this. Any help would be greatly appreciated!Tags: None
-
Hello Calebg,
From your code you would not have to do anything different to utilize the optimized value similar to the other properties you made. Can you provide a specific example of what you tried that is not working?
The general process to use an enum would be as follows:
You can use the enum from this indicator sample as a test: https://ninjatrader.com/support/help...ned_parame.htm
The property in a strategy would then look like:
and if you printed the value in an optimization:Code:[Display(GroupName = "Parameters", Description="Choose a Moving Average Type."), NinjaScriptProperty] public CustomEnumNamespace.UniversalMovingAverage MAType { get;set; }
Assuming a few of the check boxes were checked, we should see results like:Code:protected override void OnStateChange() { else if (State == State.DataLoaded) { Print(MAType); } }
Code:EMA WMA SMA EMA
I look forward to being of further assistance.
-
Sorry ahead of time for an abbreviated reply, but I decided to punt using enums all together, because for a couple months running I have been running into various hassles around them. For my own personal development I'll probably classify them as 'not the right tool for the job, more often than not' and make every effort to find a different structure to work with. In this case I just replace the enum with a 'standard' manual parameter input box which accepts a certain range of integer values. This makes the code not as readable I guess, but it was instantly worth it just to not have to deal with enums and now everything is working as expected.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
54 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
72 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment