Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daylight savings time Arizona

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

    Daylight savings time Arizona

    I am back testing a strategy using minute bars and IQFeed data source from Arizona back testing for 2 years.

    Can I set my offset for date time to 3 hours since that is the current difference between Arizona and EST or do I need to adjust my strategy to change the offset between 2 and 3 on the second Sunday of March and the first Sunday of November?

    Thanks,
    Erik

    #2
    Erik, I'm not sure I follow - are you looking to see your charts in EST instead or why do you consider such options?

    Thanks

    Comment


      #3
      My strategy uses minute bars. Example:

      Determine if OnBarUpdate is firing for a standard hours bar could be written like this:

      Code:
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (ToTime(Time[0]) >= 63000 && ToTime(Time[0]) < 125000) {[/SIZE]
      [SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//when day light saving time changes something like this:[/COLOR][/SIZE]
      [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (ToTime(Time[0]) >= 73000 && ToTime(Time[0]) < 135000) {[/SIZE]
      [/COLOR][/SIZE][/COLOR][/SIZE]
      or you could use a function like this so it is not hard coded and you can change it when you start the strategy depending on if it is fall back or spring ahead:
      Code:
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] timeOffset = 2;[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] TimeOffset {[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] timeOffset; }[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { timeOffset = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]value[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; }[/SIZE]
      [SIZE=2]}[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]DateTime[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] GetEastStdTime([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]DateTime[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] time) {[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] time.AddHours(timeOffset);[/SIZE]
      [SIZE=2]}[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnBarUpdate() {[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {[/SIZE]
      [SIZE=2]Print([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Converted {0} {1} to {2}."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], Time[0].ToShortTimeString(), Time[0].Kind, GetEastStdTime(Time[0]).ToShortTimeString()));[/SIZE]
      [SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//now you can always use this:[/COLOR][/SIZE]
      [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (ToTime(Time[0]) > 93000 && ToTime(Time[0]) < 155000)[/SIZE]
      [SIZE=2]}[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ex) {[/SIZE]
      [SIZE=2]Print(ex.ToString());[/SIZE]
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]throw[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
      [SIZE=2]}[/SIZE]
      [SIZE=2]}[/SIZE]
      when back testing if I go back a couple years will I need a new method that changes the offset on the second Sunday of March and the first Sunday of November from a 2 to a 3 to make sure I am not looking at pre and/or post data bars?


      Thanks,
      Erik

      Comment


        #4
        Hi Erik, thanks - yes, you would need to apply your custom methods to ensure the correct timestamp is accessed in this case.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X