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

find out, if indicator runs on a chart with realtime ticks coming in

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

    find out, if indicator runs on a chart with realtime ticks coming in

    Hi,

    I have an indicator, that does extensive drawing and calculation.

    When I'm adding that indicator to a chart with over 5000 bars, that has real-time ticks coming in (end date today and during session) it needs over a minute to process historical bars.

    This calculation time is going down to a couple of seconds, if I'm adding the indicator to a chart with the same amount of bars, but with let's say yesterday as the end date.

    Is it possible to find out, if an indicator runs on a chart with real-time ticks coming in, before the indicator starts to process historical bars?

    Thanks


    #2
    Hello td_910, thanks for your post.

    An indicator will always go from State.Historical to State.Realtime when it starts up. This is a performance issue due to having 5000 bars on the chart. The only thing that could be done about that is to reduce/optimize the drawing or reducing the number of bars loaded onto the chart.

    Best regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      the performance issue only occurs with real-time ticks coming in

      What do you think of the following workaround?

      Code:
      if(ChartBars != null)
      {
          if (ChartBars.Properties.To.Date >= DateTime.Now.Date)
          {
              Print ("Realtime");
              return;
          }
          else
              Print ("Historical");
      }

      Comment


        #4
        Hello td_910, thanks for your reply.

        I'm curious why the code only slows down when it hits real-time data. If you are running the script OnEachTick, then you might need to move some logic within this code block to reduce the calculations that happen on every tick:

        if(IsFirstTickOfBar){ //OnBarCloseLogic }

        If you turn on Tick Replay, I am guessing your script would go much slower in historical mode as tick replay plays back the ticks of historical bars as if they came in in real-time data. We would need to find out why the script is being slow only on incoming data.

        I look forward to assisting further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          yes, I know, it's an issue siince a couple of months, but now I can use that workaround for the time being.

          The indicator runs on OnPriceChange.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by johacnshri, Today, 05:53 AM
          0 responses
          1 view
          0 likes
          Last Post johacnshri  
          Started by ETFVoyageur, Today, 05:50 AM
          0 responses
          4 views
          0 likes
          Last Post ETFVoyageur  
          Started by DawnTreader, 05-08-2024, 05:58 PM
          17 responses
          62 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by ttrader23, 05-08-2024, 09:04 AM
          10 responses
          48 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by agclub, 04-21-2024, 08:57 PM
          6 responses
          41 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X