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 start time > end time

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

    time filter start time > end time

    I read some posts about setting a time filter whereby code is only executed within a specified time period. However, I still have some questions.

    I read about a difference between exchange based on broker and pc local time. I am testing a strategy using forex and nyc time utc-5:00 (I am using the NT7 session template for forex). I am located in a utc-3:00 area and the user is in a utc-8:00 area. What has to be done to be sure times are synced properly? Different regions often don't change between daylight and standard at the same time. Is NT7 aware of dst changes? Is Time[0] session time or local pc time?

    While testing parts of the strategy I noticed that code is executing during the do not execute time. There appears to be approx. a 2.5 hour delay from end time actual end of execution.

    This the code I am using as time filter:
    Code:
     
    if (StartTime < EndTime
    && (ToTime(Time[0]) >= StartTime && ToTime(Time[0]) <= EndTime))
    timeRangeOK = true;
    else if (StartTime > EndTime)
    {
    if ((ToTime(Time[0]) >= StartTime && ToTime(Time[0]) <= 235959) || ToTime(Time[0]) < EndTime)
    timeRangeOK = true;
    }
    else timeRangeOK = false;
    Would this be the correct code to use?

    #2
    Hello ricktek,

    Thank you for your post.
    What has to be done to be sure times are synced properly?
    Different regions often don't change between daylight and standard at the same time. Is NT7 aware of dst changes?
    NinjaTrader uses the time the PC is set to. This includes the time zone the PC is set to as well.
    Is Time[0] session time or local pc time?
    Time[0] is the time that the bar is time stamped with. Some data feed providers timestamp their data before it is received in NinjaTrader, while other data feed providers data is timestamped with the pc time when received in NinjaTrader.
    This the code I am using as time filter:
    Code:
    if (StartTime < EndTime
    && (ToTime(Time[0]) >= StartTime && ToTime(Time[0]) <= EndTime))
    timeRangeOK = true;
    else if (StartTime > EndTime)
    {
    if ((ToTime(Time[0]) >= StartTime && ToTime(Time[0]) <= 235959) || ToTime(Time[0]) < EndTime)
    timeRangeOK = true;
    }
    else timeRangeOK = false;
    Would this be the correct code to use?
    This would work to filter out the times you do not wish to trade.

    For a reference sample on using a time filter please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3226

    Please let me know if I may be of further assistance.

    Comment


      #3
      Thanks for your clarification. I'm still a bit fuzzy on NT time use. When you write NinjaTrader uses the time the PC is set to, in what way? where? If Time[0] is the bar's timestamp, when does NT use local pc time? How would that affect the code sample I posted or would it?

      Comment


        #4
        Hello ricktek,

        Thank you for your response.

        My mistake on that part, the fact that the bars are timestamped or not by the data feed provider really has no effect on this matter.

        Time[0] will pull the time of the bar close, this would be based on the time of the PC. your method of checking the StartTime and EndTime will work regardless of the Time Zone settings of the PC.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Now I'm more confused than ever. If someone in Los Angeles sets a Forex strategy's parameters StartTime to 173000 and End Time to 63000 and the timestamp on the bars from the provider are set for Eastern Time, will NT use Pacific Time (on the local PC) or the Eastern Time timestamp to filter the data? When does NT use local PC time and when does it use the bar's timestamp? That makes a huge difference.

          Can anybody explain that?

          Comment


            #6
            Hello ricktek,

            Thank you for your response.

            If the data feed provider time stamps the data before it is received NinjaTrader will still convert that to the PC's time zone. So if you are in Chicago but your data feed provider's server is in New York and they time stamp with Eastern Time your data is still going to reflect Chicago time (Central) as your PC is set to Chicago in this scenario.

            Please let me know if you have any questions.

            Comment


              #7
              That takes me another step closer to the answer, but how does that affect parameters settings for a time filter? If it is 08:00 in NYC provider's time, 07:00 on a Chicago user's PC and the parameter StartTime setting is 08:30, will a strategy start trading at 08:30 NYC time (07:30 Chicago) or the user's 08:30 Chicago PC time (09:30 NYC)?

              Would a user have to set a time filter's StartTime/EndTime parameters to timestamp time or local time?

              Comment


                #8
                Hello ricktek,

                Thank you for your response.

                They would set the two parameters to their local time on their PC.

                Please let me know if I may be of further assistance.

                Comment


                  #9
                  Thanks for responding to the second question. So, does that mean the answer to the first question is that trading would start at 9:30 NYC time?

                  Comment


                    #10
                    Hello ricktek,

                    That is correct.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by AaronKoRn, Yesterday, 09:49 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post AaronKoRn  
                    Started by carnitron, Yesterday, 08:42 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post carnitron  
                    Started by strategist007, Yesterday, 07:51 PM
                    0 responses
                    12 views
                    0 likes
                    Last Post strategist007  
                    Started by StockTrader88, 03-06-2021, 08:58 AM
                    44 responses
                    3,982 views
                    3 likes
                    Last Post jhudas88  
                    Started by rbeckmann05, Yesterday, 06:48 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post rbeckmann05  
                    Working...
                    X