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 LiamTwine, Today, 08:10 AM
            0 responses
            1 view
            0 likes
            Last Post LiamTwine  
            Started by Balage0922, Today, 07:38 AM
            0 responses
            5 views
            0 likes
            Last Post Balage0922  
            Started by JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            19 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            6 views
            0 likes
            Last Post Creamers  
            Working...
            X