Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time property

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

    Time property

    Hi,
    I want to create a time property for my strategy such that I can optimize it based on start and end time. For example, if start time is 8:30 and end time is 12:00 noon, I would want my strategy to only take trades falling within that timeframe. What is the best way to write these properties so that I can use the optimizer to increment the time by 15 minute increments? Clearly, text won't work. What does?
    Thanks ... Ed

    #2
    Hi edstaffin,

    To optimize over the start and end time, use a start hour variable and a separate start minute variable, as well as an end hour variable and an end minute variable.

    Then add them together with:

    ((startHourVariable * 100) + startMinuteVariable) * 100.

    So 14 as the hour and 33 as the minute becomes 143300. 143300 would be equal to 2:33 PM.

    By having these as separate variables, they can be incremented.

    Or these could be used as the hour an minute for timespan.

    TimeSpan startTime;
    startTime = new TimeSpan(StartHour, StartMinute, 0);
    Last edited by NinjaTrader_ChelseaB; 06-17-2021, 11:37 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    47 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    15 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    21 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X