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, 05-11-2026, 05:56 AM
    0 responses
    28 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    183 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    336 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    261 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X