Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Treatment of Time

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

    Treatment of Time

    My strategy is intended to trade only during several windows. I have a function called IsTimeWithin(a, b) which will return true if:

    Code:
    ToTime(Time[0]) >= a && ToTime(Time[0]) <= b)
    So, if we are currently outside the trading windows, the strategy is not allowed to trade.

    My problem now is that if one of the windows is say, 22:00 to 02:00, will I need to rewrite the function to use a different logic if the closing time (b) is lesser than the opening time (a)?

    Next, I have a function that does something after an offset of time after an event occurs. If the event occurs at 23:55 and the offset is 10 minutes, the trigger is set
    by 235500 + 001000 which would give 240500. When dealing with time, will NT recognize that 240500 is equivalent to 000500 or do I have to add additional logic to deal with times > 240000?

    Thanks

    #2
    Hi wuilengh, yes then the filter function would need to changed for this to be evaluated as you would expect, for example :

    if (ToTime(Time[0]) >= 220000 && ToTime(Time[0]) <= 235959
    ||
    ToTime(Time[0]) >= 000000 && ToTime(Time[0]) <= 020000)

    The int 240500 would not be recognized, you could though work with the more advanced C# DateTime objects and add your offset here with the .Add

    Returns a new DateTime that adds the specified number of minutes to the value of this instance.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by funk10101, Today, 09:43 PM
    0 responses
    2 views
    0 likes
    Last Post funk10101  
    Started by pkefal, 04-11-2024, 07:39 AM
    11 responses
    36 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Yesterday, 08:51 AM
    8 responses
    44 views
    0 likes
    Last Post bill2023  
    Started by yertle, Today, 08:38 AM
    6 responses
    25 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by algospoke, Yesterday, 06:40 PM
    2 responses
    24 views
    0 likes
    Last Post algospoke  
    Working...
    X