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

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 kujista, Today, 06:23 AM
                0 responses
                1 view
                0 likes
                Last Post kujista
                by kujista
                 
                Started by traderqz, Yesterday, 04:32 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by f.saeidi, Today, 05:56 AM
                1 response
                4 views
                0 likes
                Last Post Jltarrau  
                Started by Jltarrau, Today, 05:57 AM
                0 responses
                4 views
                0 likes
                Last Post Jltarrau  
                Started by Stanfillirenfro, Yesterday, 09:19 AM
                7 responses
                52 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X