Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ender_wiggum, Today, 09:50 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by rajendrasubedi2023, Today, 09:50 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by geotrades1, Today, 10:02 AM
    0 responses
    4 views
    0 likes
    Last Post geotrades1  
    Started by bmartz, Today, 09:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by geddyisodin, Today, 05:20 AM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X