Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time filter for one session that spans 2 days because of timezone difference

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

    Time filter for one session that spans 2 days because of timezone difference

    Hi,

    What is the best way to implement a time filter that is across 2 days where the start time is late in the pm say 220000 and then end time is early in the am 080000?

    Would this be ok?

    Code:
    if(ToTime(Time[0]) >= 220000 && ToTime(Time[0]) < 000000 || ToTime(Time[0]) >= 000000 && ToTime(Time[0]) < 080000)
    If anyone has any suggestions that would be much appreciated.

    Regards,
    suprsnipes

    #2
    Hi Suprsnipes,

    The code you gave is a great start to the time filter.In the first series of ToTime(), the second ToTime() is checking if the time is less than 000000, which in a time standard does not exist. One small change though would make this work.

    Change the second
    Code:
    ToTime(Time[0]) < 000000
    to
    Code:
    ToTime(Time[0]) <= 235959
    This will ensure that the time filter is for the correct time and calculating up to 11:59:59pm and not 00:00:00.

    I would also get rid of ToTime(Time[0]) <= 000000 since every time stamp will be greater than 000000 and no need to tell the program that.

    Code:
    ToTime(Time[0]) >= 220000 && ToTime(Time[0]) <= 235959 || ToTime(Time[0]) < 080000)
    Let me know if I can be of further assistance
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    65 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X