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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    55 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    142 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X