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

Forcing OnBarUpdate()

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

    Forcing OnBarUpdate()

    I ran indicator on historical data with COBC set to false on 1 Min bar series.
    inside the main indicator every 1 min I called the Update( ) of another indicator which containes 5 Min bar series.

    I do it as follow.

    m_PAInd = PAInd(BarsArray[(int)PA_BarPeriod_e.Bar5Min]);
    m_PAInd.Update();

    I added a print log inside the OnBarUpdate() of PAInd indicator .

    the result was that the OBU of PAInd indicator has been called every 5 min and not every 1 min.

    the COBC of PAInd indicator was set to false.


    accoring to NT 7 help in order to force OBU it needs to call the Update() methods

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

    1. Does it work on historical data too?

    2. whats the NT policy regarding Update() method ?

    3. In real time if COBC= false does the call to update shold trig the OBU every time I call Update?

    4. if COBC of the Main indicator set to true and I call another indicator update does it trig the OBU of the called indicator ?

    #2
    Hello levikNT,

    1. Yes, this does work Historically but I am not sure that it is going to process how you are expecting it. Calling the Update() will for the OnBarUpdate() to be called but it will not change the DataSeries or the different time frame it will still have the same 5 Minute time frame that you have given it. It you would like to have it update on a 1 Minute interval as well you may want to add a 1 Minute Time Frame inside of the "PAInd" so that you do not have to call the Update();

    2. Not sure exactly what you mean by policy, but the Update() method is going to be mainly used for making sure you have the correct value of a variable like when you are exposing a variable in the following reference.


    3. Could you clarify this or give me an example?

    4. With COBC set to false, any indicator that call inside of the OBU in your main script will be called on every tick of data as well.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thank you,

      If I understand, Calling an update will trig the OBU but it will not change the DataSeries or the different time frame which it make sense , but I should see the print log that I added to the updated indicator every 1 min which I don't I only see the print log in 5 min resollution

      Comment


        #4
        Hello levikNT,

        How are you printing out the time in your logs?
        JCNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_JC View Post
          Hello levikNT,

          How are you printing out the time in your logs?
          I am using the following print log:
          Print("KobiPAInd: CurrentBar = " + CurrentBar + " " + "Open = " + Open[0] + " " + "Close = " + Close[0] + " " + "High = " + High[0] + " " + "Low = " + Low[0] + " "+ Time[0].ToString() );

          This print is in the start of the OBU and I should see it every 1 min since I am calling Update() every 1 Min.

          Comment


            #6
            LevikNT,

            Would you be willing to send me the whole script so I may test this out on my end?
            You can send me the script to support[at]ninjatrader[dot]com and include ATTN Cal in the subject.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hello levikNT,

              The "Time[0]" is always going to be printing out the time stamp of the bar, so even if it is called on every 1 minute interval it will still only print out 5 Minute values.

              If you want the historical values for the 1 minute you would want to either add a 1 minute time frame in the "PAInd" indicator or create two instances of the "PAInd" in your strategy so you have a 1 and 5 minute time frames of them.



              Let us know if you have any questions.
              JCNinjaTrader Customer Service

              Comment


                #8
                Thanks for replay,

                I agree regarding to Time[0], but I should see this line printed 5 times for every 5min bar but it printed only once.
                furthermore I added a counter to the print and the counter was increase every 5 Min and not every 1Min as OBU forced.

                I know that I can do it in other way but I need to understand the Update() method.

                I searched the forum for more thread regarding this issue and I found a post from NinjaTrader_Brett (11-21-2012)
                and he said that for COBC= true NT wont force OBU to run if it already has processed that bar.
                if COBC= FALSE however then it would recalculate each time.

                1. is it right?
                2. if COBC= false and I run historic data does OBU will trig or Only in real time OBU will force for each time(tick).

                Thanks,
                kobi
                Last edited by levikNT; 11-12-2013, 08:18 AM.

                Comment


                  #9
                  Hello kobi,

                  1. Yes, that is correct.

                  2. Only in real-time will OBU be called on each tick of information. When NinjaTrader is processing anything on Historical Data it will be at the close of each bar like COBC = False, because it is not guaranteed to have intrabar data.

                  Let me try to explain it in a different way. You will only use the Update() method when you are accessing a "Non-DataSeries" object. This is because DataSeries objects will trigger the OnBarUpdate method to be called on the indicator, but other custom objects like IntSeries, BoolSeries, ect... do not invoke the OnBarUpdate method in the Indicator so the Update() is necessary to make sure that you are getting the correct value for this object.

                  Let us know if you have any questions.
                  JCNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by briansaul, Today, 05:31 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post briansaul  
                  Started by fwendolynlpxz, Today, 05:19 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post fwendolynlpxz  
                  Started by traderqz, Yesterday, 12:06 AM
                  11 responses
                  28 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by PaulMohn, Today, 03:49 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post PaulMohn  
                  Started by inanazsocial, Today, 01:15 AM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Working...
                  X