Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Start and end of regular session?

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

    Start and end of regular session?

    I am running 1 minute bar strategies against Nyse and Nasdaq instruments. I am in Arizona. Gathering information in the premarket and post market times and placing trades during regular trading hours.

    I have this code in my initialize routine:

    Code:
    [SIZE=1][SIZE=2]SessionData = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"US Equities ETH"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]CalculateOnBarClose = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE][/SIZE]
    These properties seem to backtest fine. Do they look valid for live trading or do you see issues with them? I am trying to get around reconfiguring for daylight saving time. Just wondering if I am on the right track.

    Code:
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IsFirstBarOfRegSess { [/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]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (Bars.FirstBarOfSession && ToTime(GetEastStdTime(Time[0])) > 93000 && ToTime(GetEastStdTime(Time[0])) <= 103000) {[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]  return [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]} [/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]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IsLastBarOfRegSess { [/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]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (Bars.LastBarOfSession && ToTime(GetEastStdTime(Time[0])) >= 133000 && ToTime(GetEastStdTime(Time[0])) <= 160000) {[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]  return [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]} [/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]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IsRegSess { [/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] (ToTime(GetEastStdTime(Time[0])) > 93000 && ToTime(GetEastStdTime(Time[0])) <= 160000); [/SIZE]
    [SIZE=2]} [/SIZE]
    [SIZE=2]}[/SIZE]
     
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/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=#2b91af][SIZE=2][COLOR=#2b91af] TimeZoneInfo[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] EastStdInfo;[/SIZE]
    [SIZE=2] EastStdInfo = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]TimeZoneInfo[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].FindSystemTimeZoneById([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Eastern Standard Time"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]TimeZoneInfo[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].ConvertTime(time, EastStdInfo);[/SIZE]
    [SIZE=2]}[/SIZE]
    Thanks,
    Erik

    #2
    Hi Erik, the idea seems sound to me from a quick check.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    65 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    35 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Working...
    X