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 algospoke, Yesterday, 06:40 PM
    2 responses
    19 views
    0 likes
    Last Post algospoke  
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    45 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    21 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    181 views
    0 likes
    Last Post jeronymite  
    Working...
    X