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