Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Force indicator update for custom data series

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

    Force indicator update for custom data series

    Hello,

    While doing backtest (so calc on bar close = true) I have my own custom data series, and I'd like to look at an indicator value based on it after setting the custom ds current bar value to a value I choose.

    So, for custom data series ds, I have

    SMA(ds,14)

    and I set

    ds.Set(myval)

    but SMA(ds,14) doesn't change. Is there any way I can get it to recalculate?

    thanks
    Dave

    #2
    Hello,

    There would be no way to force it inside of an OnBarUpdate.

    Otherwise OnBarUpdate will cause it to reset. Otherwise you needed to move the dx.Set() code above SMA(ds, Period) call so that you run this with the set value.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Thanks Brett,

      OBU does not cause it to update if for another series (I have 1min primary and 1tick secondary) I'm trying to do this on the secondary.

      I do have the ds.set call above the SMA call (otherwise how could I expect anything to have changed)

      Unfortunately, although ds[0] has changed, SMA(ds,14) has not. That is exactly my problem.

      regards
      Dave

      Comment


        #4
        Would need more information to assist you here.

        But more then likely what your running into is BarsInProgress check issue or something related to the multi series.

        Also, if that data series should be running on the secondary series you must be sure you have the data series set to be in sync with the secondary series. This may be what you are running into:

        Note: In NinjaTrader 8 It is no longer needed to use an indicator to sync a secondary series. This can be done directly from the Series<T> (https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?seriest.htm) constructor. This post is left for historical purposes. Series objects are useful for


        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Thanks Brett,

          No, the data series I'm using is synced to the primary, which gives me a bit of a clue as to how they work.

          Here's what I'm trying to do. In backest, you can't use calc on bar close = false. I have primary 1min, sec 1tick. I want to have an SMA on the primary update for every bar (tick) of the secondary (in the same way it would for live with COBC = false). My idea was simply to store the closes from the primary into a data series. I didn't know dataseries was so close coupled to bars.

          I wanted to update the primary ds[0] for each tick of the secondary. This works, ds[0] is updated. The indicator, SMA, based on ds does not update (presumably until the primary bar OBU) and I can't find any way to get it to update.

          I'm trying to work around this limitation of Ninja for backtesting intra bar stuff.

          thanks
          Dave

          Comment


            #6
            I see, alright yes this is expected.

            Here is a breakdown on how multi series works.

            Example is a 5 minute bar on primary and 1 minute bar on secondary: Here is how the processing works:


            OnBarUpdate0
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate0
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate1
            OnBarUpdate0



            If I could draw an arrow here I would draw up to the last OnBarUpdate0. You cannot update anything variables specific to this data series until the OnBarUpdate runs. You can see here that even though you are doing some processing intra bar it wont reflect or update the value until the next on bar update for the primary series. Though the value in the OnBarUpdate1 is correct and will be reflected correctly in the next OnBarUpdate0.

            If you want some output displayed or updated instra bar granularity your going to need to do this processing or outputting in the secondary series. Not in the primary series.

            -Brett
            BrettNinjaTrader Product Management

            Comment


              #7
              Originally posted by NinjaTrader_Brett View Post
              I see, alright yes this is expected.

              You cannot update anything variables specific to this data series until the OnBarUpdate runs. You can see here that even though you are doing some processing intra bar it wont reflect or update the value until the next on bar update for the primary series. Though the value in the OnBarUpdate1 is correct and will be reflected correctly in the next OnBarUpdate0.
              Thanks Brett,

              I know how multi series works, and that's not what I'm asking. I'm asking for a workaround for the limitation. What you say above is not correct. The ds I mentioned is specific to the primary series, and I can update it in the secondary series. That works fine.

              Comment


                #8
                dave,

                there would be no way to alter the multi series processing or force an update on the primary series.

                I do not see a case where this would be desired either as any type of forced update could cause unpredictable results and differences in backtesting from the NinjaTrader method of OnBarUpdate in multi series.

                Every OnBarUpdate occurs when a bar is updated, you cannot force a OnBarUpdate with no bar update.

                -Brett
                BrettNinjaTrader Product Management

                Comment


                  #9
                  Well, clearly the need for this is to be able to backtest COBC = false.

                  Can you then explain this from the documentation?

                  Update()
                  This method will force the OnBarUpdate() method to be called so that indicator values are updated.

                  Comment


                    #10
                    Hello,

                    Good find, I've never had a single question on that, nor have I ever used it which is rare for me. Please give it a try and let me know if it does what you need. I'll be sure to pass on to next person who asks if it does.
                    BrettNinjaTrader Product Management

                    Comment


                      #11
                      It doesn't work. Just does nothing, whether you call it from your strat or from the indicator. What does seem to work, maybe, although I'm still testing, is calling a proc in your indicator which calls OBU.

                      Comment


                        #12
                        please let me know what you find. your in uncharted waters here so I'm of very limited assistance here with this.

                        If Update does not work as you expect. Please send me the test script your using for it that is simplified and I'll forward it to development.

                        Thanks.
                        BrettNinjaTrader Product Management

                        Comment


                          #13
                          AT Interface

                          I have created OIF.txt files for certain trades through OIF Builder and saved them off to a certain directory.

                          For example:
                          OIFBUY.txt is

                          CANCELALLORDERS;;;;;;;;;;;;
                          CLOSEPOSITION;SIM101;ES 09-11;;;;;;;;;;
                          PLACE;SIM101;ES 09-11;BUY;1;MARKET;0;0;DAY;;;;

                          and
                          OIFSELL.txt is

                          CANCELALLORDERS;;;;;;;;;;;;
                          CLOSEPOSITION;SIM101;ES 09-11;;;;;;;;;;
                          PLACE;SIM101;ES 09-11;SELL;1;MARKET;0;0;DAY;;;;


                          Yesterday, I would simply copy and paste them into the Incoming directory and the AT interface would execute them just fine.

                          Today they just sit there in the incoming directory and will not execute. The AT interface is definitely ON

                          What am I doing wrong? What is the best practice for populating the incoming directory with OIF files not using OIF Builder?
                          Thanks

                          Comment


                            #14
                            Hello,

                            Best practice is to have one command per file.

                            This should then work no problem.
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              calling OBU seems to work. Update() doesn't in the case I described, but I don't have a test script any more - should be easy enough to test though.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              77 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              27 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              63 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X