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

Optimizing an enum list in strategy analyzer

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

    Optimizing an enum list in strategy analyzer

    There are minimal number of posts on this, all seem to point to the same 3 posts, and one being in NT8. I understand we can only optimize integers and doubles, so I would need the Ninjascript to change the enum list to one of those types. I think I'm missing something blatantly easy that is preventing, the two enum lists from being optimized in strategy analyzer. I'm expecting that in the Parameters box i have the ability to optimize TargetLevelHigh and TargetLevelLow by increments of 5 to call the proper data series. Any help is appreciated!

    region variables
    private Band targetlevelhigh = Band.TargetL30;
    private Band targetlevellow = Band.TargetL10;

    DataSeries TargHigh;
    DataSeries TargLow;

    TargHigh = new DataSeries(this);
    TargLow = new DataSeries(this);​

    protected override void OnBarUpdate()
    {
    if (FirstTickOfBar)
    {
    switch (targetlevelhigh)
    {
    case Band.TargetL30:
    {
    TargHigh.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL25:
    {
    TargHigh.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL20:
    {
    TargHigh.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL15:
    {
    TargHigh.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL10:
    {
    TargHigh.Set(blah blah blah indicator);
    break;
    }
    }

    switch (targetlevellow)
    {
    case Band.TargetL30:
    {
    TargLow.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL25:
    {
    TargLow.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL20:
    {
    TargLow.Set(blah blah blah indicator);
    break;
    }

    case Band.TargetL15:
    {
    TargLow.Set(blah blah blah indicator);
    }

    case Band.TargetL10:
    {
    TargLow.Set(blah blah blah indicator);
    }
    }
    }

    region Properties [Description("Maximum allowable position size")]
    [GridCategory("Parameters")]
    public Band TargetLevelHigh
    {
    get { return targetlevelhigh; }
    set { targetlevelhigh = value; }
    }

    [Description("Maximum allowable position size")]
    [GridCategory("Parameters")]
    public Band TargetLevelLow
    {
    get { return targetlevellow; }
    set { targetlevellow = value; }
    }
    #endregion​

    public enum Band : int
    {
    TargetL30 = -30,
    TargetL25 = -25,
    TargetL20 = -20,
    TargetL15 = -15,
    TargetL10 = -10,

    }​​​​​

    #2
    Hello nmk85roll,

    Correct, enums cannot be optimized over in NinjaTrader 7 but can be optimized over as a new feature of NinjaTrader 8.

    " I'm expecting that in the Parameters box i have the ability to optimize TargetLevelHigh and TargetLevelLow by increments of 5 to call the proper data series."

    This will not work in NinjaTrader 7. You would have to use NinjaTrader 8 to achieve that with an enum.

    Instead, you can use an integer.

    public int TargetLevelHigh
    {
    get { return targetLevelHigh; }
    set { targetLevelHigh = value; }
    }

    In OnBarUpdate()
    if (TargetLevelHigh == 10)
    {
    // execute code if TargetLevelHigh is 10
    }



    Please note, NinjaTrader 7 is no longer in active development and we are no longer considering new feature requests or changes for NinjaTrader 7. Main development has shifted to our flagship platform NinjaTrader 8. This does mean updates from brokerages, data feeds, or operating systems that require an update in NinjaTrader will not be implemented in NinjaTrader 7 and may cause an interruption in service.

    While there is not a set ETA for the complete discontinuation of NinjaTrader 7, we highly recommend transitioning to NinjaTrader 8 as soon as possible before NinjaTrader 7 reaches its end of life to prevent interruption of service.

    Click below to download NinjaTrader 8.
    http://ninjatrader.com/GetStarted
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    238 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    4 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Started by pechtri, 06-22-2023, 02:31 AM
    10 responses
    125 views
    0 likes
    Last Post Leeroy_Jenkins  
    Working...
    X