Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.FirstBarOfSession

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

    Bars.FirstBarOfSession

    I guess I need a better understanding of what a "session" is.
    I placed the following code in OnBarUpdate()
    Code:
    if (Bars.FirstBarOfSession && FirstTickOfBar)
    {
    Print ("Time is:" + String.Format("{0:d/M/yyyy HH:mm:ss}", Time[0]) + " now is:" + DateTime.Now.ToString());
    }
    I ran against 10 days of data on the Market Replay. I have a session template that I created. Let's say mon-fri 6:30 am to 11:00 am.
    The outcome I was expecting or at least wanting was for every day at 6:30 am for the print statement above to execute.
    Am I mis-understanding this? Or, how do I correct connect my strategy code to the session template I want to use?

    #2
    A "session" is defined as any session definitions you have in your Session Template.

    Your code will print once at the very first event per session.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      So a "session" would be Monday 6:30am to 11am and the next session would be Tuesday 6:30am to 11am. This means my strategy is not using the correct session template. How do I attach the strategy to the session template?
      Thanks

      Comment


        #4
        You can choose the session template a strategy runs on by making the session template of the instrument on the chart to the session template you want.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Ok, on the strategy tab I found where I can edit the strategy and choose the session template. Is there a way I can do this programmatically in the intialize()?

          Comment


            #6
            trtrav,

            You cannot programmatically set a Session Template. If you have a Session Template you always want to use with a particular instrument you can set the desired Session Template as the default one in the Instrument Manager for that instrument though.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            650 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            577 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X