Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Testing enums values work as expected in standard backtest, but not in optimization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!

    #2
    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:

    Code:
    [Display(GroupName = "Parameters", Description="Choose a Moving Average Type."), NinjaScriptProperty]
    public CustomEnumNamespace.UniversalMovingAverage MAType
    {
         get;set;
     }
    and if you printed the value in an optimization:
    Code:
    protected override void OnStateChange()
    {
       else if (State == State.DataLoaded)
       {
           Print(MAType);
        }
    }
    Assuming a few of the check boxes were checked, we should see results like:

    Code:
    EMA
    WMA
    SMA
    EMA

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      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 DavidHP, Today, 07:56 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by kujista, Today, 06:23 AM
      3 responses
      6 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by Mindset, Yesterday, 02:04 AM
      2 responses
      18 views
      0 likes
      Last Post NinjaTrader_RyanS  
      Started by f.saeidi, Today, 08:03 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by samish18, 04-17-2024, 08:57 AM
      15 responses
      53 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X