Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator w/CalculateOnBarClose = false

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

    Indicator w/CalculateOnBarClose = false

    I'm testing an indicator on a live data feed with CalculateOnBarClose = false. My understanding is that this means that Close[0] is the most recent live tick and Close[j] (i.e., all [j] which are >0 ) is a historical close.

    A simple question:
    I don't see the indicator updating with each new tick, I only see a new indicator value with each bar close. How do I see the live tick-by-tick value of the indicator?

    #2
    Hello bluelou,

    Setting CalculateOnBarClose (COBC) to false you should see Close[0] being updated on each incoming tick of data inside of OnBarUpdate().

    Are you doing your calculations inside of OnBarUpdate?

    Also, do you have any conditions before you are checking the values of your Indicators?

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      JC, I'm pretty sure I figured it out. I had COBC = false in my code but I didn't realize I needed to set Data: COBC = False in the indicator window on the chart.

      Comment


        #4
        JC,
        A new problem. Now I have the indicator updating in real time but the indicator values have changed dramatically. For instance, with the lookback = 10 bars, when COBC = true the indicator evaluates the prices in the full lookback sequence. With COBC = false, the indicator is only considering the price since the previous bar close. Any idea why this is happening?

        With COBC = false would a statement like the following cause a problem for the historical bars within a lookback period? I.e., calling the Open as an object and saving it into a List?

        double lowestLow = _data[end].Open;

        Would I need to use FirstTickOfBar as confirmation of a bar close before saving it into a data structure such as a List when COBC = false?
        Last edited by bluelou; 10-10-2013, 01:53 PM.

        Comment


          #5
          Hello bluelou,

          Indicators should always look back on the full data that it is being passed to regardless of the COBC settings. How are you checking the values?

          Lists are something that we do not support here at NinjaTrader but can be done inside of NinjaScript. Here is a link to Microsoft's MSDN that has an example of how to use lists that you may view for an example.
          Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.


          If you only wanted to save one value per bar inside of your list then yes.

          Happy to be of further assistance.
          JCNinjaTrader Customer Service

          Comment


            #6
            JC,
            Here's what I'm looking to do. I need to calculate a percentage change in price; i.e., numerator / denominator -1

            1) Numerator:
            Given COBC = false, for incomplete bars I need the numerator to be the real-time price and for completed bars (i.e., historical bars) I need a true historical Close[ ] - I'm guessing I'd get that with the FirstTickOfBar property. Is that correct?

            2) Denominator:
            The denominator is a historical close stored in a List.
            So, with COBC = false AND FirstTickOfBar I need to assure that only the true bar Close is stored in the List. Furthermore, I'll need to calculate the percent change using the numerator as described in 1) above in combination with a denominator which is a historical close stored in a List. Are there any limitations in NT that will prevent me from doing this or do you foresee any problems?

            Thanks,
            Lou
            Last edited by bluelou; 10-10-2013, 04:54 PM.

            Comment


              #7
              Hello Lou,

              I do not see anything that you would run into and you should not have to create your own list, you should be able to use the DataSeries that NinjaTraders stores for the bar data. So something like the following should work.

              Code:
              double netChange = Close[0] / ( Close[1] -1 );
              Close[0] will always be the current bars so it will represent the incoming ticks of data and Close[1] will always represent the last bar so for example in a 5 minute DataSeries if it 9:07 then the 9:10 bar is still being built (Close[0]) but the 9:05 bar (Close[1]) will not change until the 9:10 bar finishes.
              JCNinjaTrader Customer Service

              Comment


                #8
                JC,
                I gave a simplified example. There are a lot of rules that go into finding the correct denominator. Referring back to the more detailed question in my previous posting, and assuming that I have to use a List, could you please confirm/answer the following questions?

                1) Numerator:
                I'm guessing I'd get that with the FirstTickOfBar property. Is that correct?

                2) Denominator:
                Are there any limitations in NT that will prevent me from doing this or do you foresee any problems?


                Thanks much for your help,
                Lou


                Originally posted by NinjaTrader_JC View Post
                Hello Lou,

                I do not see anything that you would run into and you should not have to create your own list, you should be able to use the DataSeries that NinjaTraders stores for the bar data. So something like the following should work.

                Code:
                double netChange = Close[0] / ( Close[1] -1 );
                Close[0] will always be the current bars so it will represent the incoming ticks of data and Close[1] will always represent the last bar so for example in a 5 minute DataSeries if it 9:07 then the 9:10 bar is still being built (Close[0]) but the 9:05 bar (Close[1]) will not change until the 9:10 bar finishes.

                Comment


                  #9
                  Hello Lou,

                  Originally posted by bluelou View Post
                  1) Numerator:
                  Given COBC = false, for incomplete bars I need the numerator to be the real-time price and for completed bars (i.e., historical bars) I need a true historical Close[ ] - I'm guessing I'd get that with the FirstTickOfBar property. Is that correct?

                  1) Numerator:
                  I'm guessing I'd get that with the FirstTickOfBar property. Is that correct?

                  2) Denominator:
                  The denominator is a historical close stored in a List.
                  So, with COBC = false AND FirstTickOfBar I need to assure that only the true bar Close is stored in the List. Furthermore, I'll need to calculate the percent change using the numerator as described in 1) above in combination with a denominator which is a historical close stored in a List. Are there any limitations in NT that will prevent me from doing this or do you foresee any problems?

                  2) Denominator:
                  Are there any limitations in NT that will prevent me from doing this or do you foresee any problems?
                  Let me try to explain this in a different way. You would only want to use FirstTickOfBar if you want to separate out your logic to the close of the bar or to simulate COBC = true, but you would still use Close[0] for the real-time price.

                  So setting a variable inside of your List you would want to use FirstTickOfBar but referencing the data, you may not need this.

                  Let me know if have any questions.
                  JCNinjaTrader Customer Service

                  Comment


                    #10
                    JC,
                    That makes a lot of sense. I think this will work. I'll keep you posted.

                    Thanks,
                    Lou

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by frslvr, 04-11-2024, 07:26 AM
                    8 responses
                    111 views
                    1 like
                    Last Post NinjaTrader_BrandonH  
                    Started by stafe, 04-15-2024, 08:34 PM
                    10 responses
                    44 views
                    0 likes
                    Last Post stafe
                    by stafe
                     
                    Started by rocketman7, Today, 09:41 AM
                    3 responses
                    8 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by traderqz, Today, 09:44 AM
                    2 responses
                    5 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by rocketman7, Today, 02:12 AM
                    7 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X