Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Taking action at the end of a session

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

    Taking action at the end of a session

    Hi,
    I'm running a backtest on a strategy with sessions configured from 8AM to 9PM.
    I want, at the end of the day, to output a simple report about the day. The point is that I don't know how to do that. Obviously, there is no such thing as a "lastBarOfSession". The dispose method is called at the end of backtest but not at the end of each session.

    Outputing in the onbarupdate method, while checking for a specific time won't work, since somedays there is quotations until 6PM while other days will have quotations up to 8PM.

    Does anyone have an idea of how I should do.

    The only working idea i had so far is to call the output method at each onbarupdate call, each time overwriting the report with the latest values, which is a bit a shame in terms of waste of ressources.

    Thanks in advance.

    #2
    How about:
    Code:
    if (Bars.FirstBarOfSession)
    {
        // your report logic here
        // print report data of previous session
    }

    Comment


      #3
      Yes, I thought about that one, which would perfectly do the trick in backtesting context.
      But when the strategy will be deployed live, I'm not very confortable to have the program waiting for the next morning (or the next monday)to output the report, because it means that ninjatrader (and the computer running it) can never be stopped), which may be an issue.

      Comment


        #4
        For realtime you could add additional logic which triggers at a specific time.

        Comment


          #5
          I'm not sure of how i could do this :
          If I understand correctly, everything must be anyway triggered from a onbarupdate call.
          If the market closes at 6PM, how can i have something triggered at 8PM? If i have a bar period of one minute, will the onbarupdate be called every minute anyway, even if there is no new quotations? In this case, how would the Close[0], High[0],...variables be populated? with the last quotation of the day?
          Sorry for insisting on this, your help is very much appreciated.

          Comment


            #6
            How about creating a report at 5:59 PM (last bar before session close)?

            If that will not work, then you could schedule a .NET timer which triggers in at 8PM (provided your strategy is running then). Note: This is beyond what we can support.

            Comment


              #7
              Thanks Dierk,

              the point is that most time the market will close at 8PM, while sometimes it may close before. So i maybe will go for the Timer option (note : and stop bothering you with this )
              The drawback of this is that it prevents from using the exact same program in backtesting and realtime context.

              Suggestion : it would be handy to have a callback function when the session ends : an onSessionEnds() method which would be triggered after(or before) NinjaTrader performs the potential exitOnClose actions

              Thank you for your help.

              Comment


                #8
                Thanks for your suggestion. We'll add it to the list.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by charlesugo_1, 05-26-2026, 05:03 PM
                0 responses
                60 views
                0 likes
                Last Post charlesugo_1  
                Started by DannyP96, 05-18-2026, 02:38 PM
                1 response
                147 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 05-11-2026, 05:56 AM
                0 responses
                162 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 05-10-2026, 08:12 PM
                0 responses
                97 views
                0 likes
                Last Post CarlTrading  
                Started by Hwop38, 05-04-2026, 07:02 PM
                0 responses
                284 views
                0 likes
                Last Post Hwop38
                by Hwop38
                 
                Working...
                X