Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter Order at Specified Time

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

    Enter Order at Specified Time

    I am trying to develop a strategy that will trade during the day at a specified time. The strategy uses daily bars to determine whether to enter or exit a trade. This strategy does not place orders at teh desired time.

    I have attached the strategy code. Obvoiusly I am doing something fundamentally wrong.

    Any help would be appreciated.

    Double Bogie
    Attached Files

    #2
    Double Bogie,

    I think you are entering the time incorrectly. see below

    ToTime()
    Definition
    Calculates an integer value representing time. NinjaScript uses the .NET DateTime structure which can be complicated for novice programmers. If you are familiar with C# you can directly use DateTime structure properties and methods for date and time comparisons otherwise use this method and the ToDay() method.

    Integer representation of time is in the following format Hmmss where 7:30 AM would be 73000 and 2:15:12 PM would be 141512.

    Method Return Value
    An int value that represents the time.

    Syntax
    ToTime(DateTime time)

    Parameters
    time
    A DateTime structure such as Time[0] - See Time property


    Examples
    // Only trade between 7:45 AM and 1:45 PM
    if (ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 134500)
    {
    // Strategy logic goes here
    }

    Comment


      #3
      Hi Double Bogie,

      ToTime(Time[0]) will access the current bar's time stamp, so if you are using daily bars this will use the bar time stamp for the day, and compare that to the times in your condition.

      A few options, Depending on why you want to use daily bars...
      1. You can apply this to minute chart, and use the CurrentDayOHL or PriorDayOHLC to monitor daily values

      2. In NT7 you can add another time series to a chart, to monitor those values.

      3. You can create a multi-time series strategy:
      TimNinjaTrader Customer Service

      Comment


        #4
        The format for the start and end times was created by Strategy Wizard, so if this format is incorrect, then Strategy Wizard needs to be fixed.

        Tim,

        Thanks, I now think I understand how it works. If I understood correctly in Ver 7 I can create an additional time series, say 1 minute, and use that time series to monitor the times to execute trades.

        Double Bogie

        Comment


          #5
          Double,

          The format is not incorrect. Both styles are acceptable.

          You can create a multi-series strategy in 6.5 already. You do not need NT7 to do this. Please see here: http://www.ninjatrader-support.com/H...ameInstruments
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

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