Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Example for passing Time/Date as a Parameter

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

    Example for passing Time/Date as a Parameter

    What is the best way to pass a time or date as a parm ?
    Do you use a string and then parse it out?
    Or is there a better way?

    #2
    imported post

    As a parameter of a method?

    private void (DateTime dateTime)
    {
    Print(dateTime.ToString());
    }


    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      Thanks Ray

      No, I was meaning as an input parm to a Indicator or Strategy.
      For example, to set the times when a strategy should trade.

      I do it now by hard coding the times in the code.

      Comment


        #4
        imported post

        I see. Sorry, DateTime input params are not supported right now. I suggest e.g. parsing an input string (as per your initial post).

        Comment


          #5
          imported post

          Another thought: if you want to set intra day limits like "begin of critical period" = 9:45 and "end of critical period"= 15:30 you could of course go with integers like 945 and 1530 and convert them to hours and minute values.

          Comment


            #6
            Could you please give me an example of using a string as an input in a strategy? I used the following and it crashed Ninja.

            in variables:

            private string addContract = "ER2 06-07";

            in properties:

            [Description("")]
            [Category("Parameters")]
            public string AddContract
            {
            get { return addContract; }
            set { AddContract = addContract; }
            }

            in initialize():

            Add(addContract, PeriodType.Second, 15);

            Thanks,

            Folls

            Comment


              #7
              The problem is that you have coded an infinite loop. It should be

              Code:
              set { addContract = value; }
              RayNinjaTrader Customer Service

              Comment


                #8
                Sorry. Thanks for your help. It must be frustrating at times for you to get non-programmers posting programming questions. There is definitely a learning curve. I think a few more weeks and I'll be fine.

                Folls

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                561 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                325 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X