Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Alternative to OnTermination()

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

    Alternative to OnTermination()

    I have an indicator that runs over historical data to perform bar by bar calculations in memory. When the last historical bar has been completed I need to write the resulting contents of memory to files. This processing takes many hours.

    I currently have the methods to write the files in OnTermination(). The issue with this is that it relies on me remembering to "terminate" correctly ... if for example, after many hours of processing, I shut down NT without first remembering to remove the indicator from the historical chart, it seems the files I need aren't written as desired.

    Is there an alternative to OnTermination() which will let the indicator know that the last historical bar has been processed, so that the files can be written?

    Thanks.

    #2
    Hello AnotherTrader,

    There is not method to do something on the last Historical bar, but you may use the "Historical" variable to see when your Indicator is running on real-time data to write your values to a file. So you may do something like:

    Code:
    if(Historical)
    {
          // Do calculations
    }
    else
    {
          // Write data to file since real-time data is coming in
    }


    Note if you would like to only write it once you may want to add an additional variable so that it only happens once.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks. Would that work if NT is not connected to a data feed?

      Originally posted by NinjaTrader_JC View Post
      Hello AnotherTrader,

      There is not method to do something on the last Historical bar, but you may use the "Historical" variable to see when your Indicator is running on real-time data to write your values to a file. So you may do something like:

      Code:
      if(Historical)
      {
            // Do calculations
      }
      else
      {
            // Write data to file since real-time data is coming in
      }


      Note if you would like to only write it once you may want to add an additional variable so that it only happens once.

      Comment


        #4
        Hello AnotherTrader,

        It would not since the Historical method is event driven by market data. Do you have any real-time data coming into NinjaTrader or are you only using this on Historical?
        JCNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_JC View Post
          Hello AnotherTrader,

          It would not since the Historical method is event driven by market data. Do you have any real-time data coming into NinjaTrader or are you only using this on Historical?
          For this processing it is just historical data.

          Comment


            #6
            Hello AnotherTrader,

            This would be a bit more difficult since NinjaTrader replies on Real-time Market Data to flag the end of the Historical Data.

            The only thing that comes to mind is using a custom event so that you may create a custom timer event that is based on your Local PC clock so that you may call code given in a time interval that would not be event driven.

            You may find an example of this at the following link.
            JCNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jonker, Today, 01:19 PM
            0 responses
            1 view
            0 likes
            Last Post Jonker
            by Jonker
             
            Started by futtrader, Today, 01:16 PM
            0 responses
            5 views
            0 likes
            Last Post futtrader  
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,790 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            838 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,294 views
            1 like
            Last Post jgualdronc  
            Working...
            X