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

Using PeriodType.ID in user parameters

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

    Using PeriodType.ID in user parameters

    How to give the user an option to select which Bars objects to Add() to the chart?

    Something like this:

    private BarsPeriod.Id bars1period = PeriodType.Day;
    [GridCategory("Parameters")] [Gui.Design.DisplayNameAttribute("Bars[1] Period")]
    public BarsPeriod.Id Bars1period { get { return bars1period; } set { bars1period = value; } }

    private BarsPeriod.Value bars1value = 1;
    [GridCategory("Parameters")] [Gui.Design.DisplayNameAttribute("Bars[1] Value")]
    public BarsPeriod.Value Bars1value { get { return bars1value; } set { bars1value = value; } }

    So later this will be possible:

    Initialize()
    {
    Add(bars1period, bars1value);
    }

    #2
    Just define the variables :
    #region Variables
    private int OT_XMA_Period = 50 ;
    private int OT_TimeUnit = 5 ;
    private PeriodType x= PeriodType.Minute;
    #endregion
    ...then add the new timeframe on initialize;
    protected override void Initialize()
    {
    Add( x ,OT_TimeUnit);
    .....
    ...

    and let user change those settings :
    #region Properties
    [Description("")] [GridCategory("Parameters")]
    public PeriodType OT_Time_Type { get { return x; } set { x = value; } }

    [Description("")] [GridCategory("Parameters")]
    public int OT_Time_Unit { get { return OT_TimeUnit; } set { OT_TimeUnit = value; } }

    Regards,
    Pablo
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    Comment


      #3
      I didn't know the correct classes. That's perfect, thanks.

      Comment


        #4
        Can the programmer set the default PeriodType as well as the PeriodValue? If so, how? and I assume you do that in the Initialize()...

        Thanks - David

        Comment


          #5
          Yes,

          the programmer set the default value on the variables definition

          private PeriodType x= PeriodType.Minute;

          then the user can change it on #region Properties
          pmaglio
          NinjaTrader Ecosystem Vendor - The Indicator Store

          Comment


            #6
            if I'm not mistaken that will set a local variable to that type. I'm wondering how to set the strategy to a specific PeriodType so when I configure the strategy I don't have to worry about that ,,,,

            Comment


              #7
              Originally posted by dadof3and3 View Post
              if I'm not mistaken that will set a local variable to that type. I'm wondering how to set the strategy to a specific PeriodType so when I configure the strategy I don't have to worry about that ,,,,
              You declare private properties in the backing store, then expose them publicly using a getter and a setter.

              Comment


                #8
                Originally posted by koganam View Post
                You declare private properties in the backing store, then expose them publicly using a getter and a setter.
                Yes, but does that change the properties of the NT strategy... I'll do some testing.

                Comment


                  #9
                  Originally posted by dadof3and3 View Post
                  Yes, but does that change the properties of the NT strategy... I'll do some testing.
                  If you expose it as public, PeriodType is an enum. It should show up as a drop-down list in the config GUI.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DJ888, 04-16-2024, 06:09 PM
                  4 responses
                  12 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by terofs, Today, 04:18 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by nandhumca, Today, 03:41 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post nandhumca  
                  Started by The_Sec, Today, 03:37 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post The_Sec
                  by The_Sec
                   
                  Started by GwFutures1988, Today, 02:48 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Working...
                  X