Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Real-time indicators and strategy

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

    Real-time indicators and strategy

    Hi,

    I have a strategy that uses a real-time indicator that I wrote myself.

    During Initialize it, I added it to my chart using:

    Add(RTIndicator(100));

    Later on, in my strategy code, in OnMarketData, I refer to the indicator as

    indicator = RTIndicator(100);
    newEntry = indicator.x[0];

    where x is a series that I calculate in the indicator.

    Is this correct? Will calling RTIndicator(100) use the data that I have been accumulating while my strategy has been running? Or will it create an entirely new indicator and start accumulating new data from that point?

    Ever since this Tuesday, I've been having trouble with my NT strategies not working and I'm trying to figure out why. I have an indicator that calculates daily values that I use on my real-time strategy, however, since this week, I'm finding that for whatever reason, the indicator is returning the previous day's values, so I'm trying to narrow down the reason why. So I'm thinking of changing my indicator to being real-time but I'm worried that it won't accumulate the proper data.

    Thanks,

    Steve

    #2
    Hi Steve,

    You're creating a new instance of your indicator. It will run the calculations again on the most recent 100 bars of historical data. Most of the time indicators are designed to work similarly on real time or historical data, but if yours does not then there can be differences.

    What version of NinjaTrader are you using? You can check with Help > About.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hi Steve,

      You're creating a new instance of your indicator. It will run the calculations again on the most recent 100 bars of historical data. Most of the time indicators are designed to work similarly on real time or historical data, but if yours does not then there can be differences.

      What version of NinjaTrader are you using? You can check with Help > About.
      Thanks Ryan. I'm using the latest version of NT, and I upgraded this week. I have no 3rd party indicators, so the install should have been straightforward.

      I'm not sure I follow. My indicator works off ticks, so are you saying that NT will store the last 100 bars of ticks for me?

      If this is creating a new instance of the indicator, how do I access the values from that indicator that I added when I initialized the strategy? Those are the values that I need.

      thanks,

      Steve

      Comment


        #4
        You're likely running into a bug discovered in R6, that can affect indicator calculations on daily charts. I suggest using instead R5 for now until this issue is fixed in our next version.

        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RyanM View Post
          You're likely running into a bug discovered in R6, that can affect indicator calculations on daily charts. I suggest using instead R5 for now until this issue is fixed in our next version.

          http://www.ninjatrader.com/download-registration.php
          Hi Ryan,

          No, this didn't help me, I still suffer from the same problem.

          Would you know the answer to my question, with respect to how do I access the data that has been accumulating in my real-time indicator? What do I need to do in order to get that data? For some reason, my strategy no longer works, so I need to figure out how to get it working, this is now the 4th day I haven't been able to trade my strategy because of this, but I only just figured out today that the strategy has the problem after a year of working fine.

          thanks,

          Steve

          Comment


            #6
            It really depends what you're coding and how you're storing / accessing values. Mind sharing a code sample so we can see what type of problem you're having? Let us know what you're expecting to see with this code snippet compared to what you're actually seeing.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Ryan,

              How do I submit my code? I would rather not post it on the forum.

              I have determined that the code worked fine in 7.0.2, but as of 7.0.5 it no longer works.

              thanks,

              Steve

              Comment


                #8
                You can send to support 'at' ninjatrader 'dot' com. Attn RyanM. Please submit as simple a script as possible, and provide steps to where we can see it break down from expected behavior.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Updating here - The issue was caused by missing OnBarUpdate() event handler. This handler is required for all strategy and indicator scripts, even if you do nothing in it.
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  369 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  572 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X