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 GussJ, 03-04-2020, 03:11 PM
    15 responses
    3,271 views
    0 likes
    Last Post xiinteractive  
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    2 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    10 responses
    403 views
    1 like
    Last Post beobast
    by beobast
     
    Working...
    X