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 CarlTrading, 03-31-2026, 09:41 PM
                1 response
                152 views
                1 like
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 04-01-2026, 02:41 AM
                0 responses
                87 views
                1 like
                Last Post CarlTrading  
                Started by CaptainJack, 03-31-2026, 11:44 PM
                0 responses
                131 views
                2 likes
                Last Post CaptainJack  
                Started by CarlTrading, 03-30-2026, 11:51 AM
                0 responses
                127 views
                1 like
                Last Post CarlTrading  
                Started by CarlTrading, 03-30-2026, 11:48 AM
                0 responses
                106 views
                0 likes
                Last Post CarlTrading  
                Working...
                X