Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-TimeFrame and COBC ?

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

    Multi-TimeFrame and COBC ?

    Hi,

    I believe I should be using a multi-timeframe strategy. This is what I want to do. The chart could have any sort of bars, but I need to calculate the difference between ticks on a second-basis. For example, say we have a range bar up on the chart, and I want to know whether the last 5 ticks moved up in progression. How would I do this?

    1. Strategy is added to a 12-tick range chart.
    2. I want the ability to know if price moved 5 number of ticks within the past 3 seconds.

    How would this be accomplished? I believe I want COBC = false for my second dataseries. But I'm unsure if NT supports this.

    Any help would be much appreciated.
    thanks!

    #2
    Hello,

    Thank you for your forum post.

    Just wanted to let you know that we received your note and that someone will respond in the morning.

    Thank You for your patience.
    BrettNinjaTrader Product Management

    Comment


      #3
      Jon, you can definitely add a more granular series to do your calcs with those bars and timestamps then (Times()). However, please keep in mind CalculateOnBarClose wil always be true in backtesting and would also apply to all series calling the OnBarUpdate().

      There's a workaround however detailed here -

      Comment


        #4
        Bertrand,

        I've added this extra series in the initialize method:

        Add(PeriodType.Second, 2);

        Now what I want to do is look at every 2 seconds (13:20:02 and 13:20:03) for example. As soon as there is a spike of 5 ticks from the beginning of 13:20:02, I want to enter the market. How is this possible exactly? Considering if COBC = true, I will only see the ticks after the seconds (2-second bar) are over? If I need COBC=false, how can I traverse through each tick of the "2-second bar"?

        Comment


          #5
          If you want to look inside a bar and find something like a 5 tick spike you will have to use COBC=false. When you set COBC=false you can only see each individual tick contained in a seconds bar in real-time. Historical bars will not have this information available as historical bars are just snapshots of the moment in time when you have OHLC for the bar.

          To see each tick as it comes in you would just use Close[0] when using COBC=false in real-time. Since you did Add() it would be the secondary series you want the tick information from so you can also do Closes[1][0].
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Josh View Post
            If you want to look inside a bar and find something like a 5 tick spike you will have to use COBC=false. When you set COBC=false you can only see each individual tick contained in a seconds bar in real-time. Historical bars will not have this information available as historical bars are just snapshots of the moment in time when you have OHLC for the bar.

            To see each tick as it comes in you would just use Close[0] when using COBC=false in real-time. Since you did Add() it would be the secondary series you want the tick information from so you can also do Closes[1][0].

            Josh, Thanks for the info. I plan on using a 2-second bar as my secondary Period.
            I want to traverse through all the trades in this bar. How can I do that? This is what I have so far:

            1. In the init function I add the other dataseries:
            Add(PeriodType.Second, 2);

            2. In the OnBarUpdate I check for BarsInProgress to only check the second Bars object:

            if (BarsInProgress == 1) // seconds series
            {
            CalculateEntry();
            }

            3. The CalculateEntry method is where I want to traverse through all the ticks within this bar. I can't find any documentation relating to how to access the information inside this bar.

            Essentially I simply want to go through the all the trades (in sequential order for that 2 second bar) and compare them to one another. I tried using
            BarsArray[1].TickCount but that didn't result in anything beneficial either.

            Is there a way to use foreach on the ticks in the BarsArray[1]?

            thanks!
            Last edited by jonmoron; 08-31-2010, 10:55 PM. Reason: added question about foreach

            Comment


              #7
              jonmoron, there's unfortunately no dedicated method for this - the tickcount of this bar is pretty close but will be just the cumulative trade # that took place.

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                jonmoron, there's unfortunately no dedicated method for this - the tickcount of this bar is pretty close but will be just the cumulative trade # that took place.
                Bertrand,

                You're telling me there is no way of accessing (a collection) all of trades within a Bar?
                How is that possible??

                Comment


                  #9
                  Sorry, I don't follow you jon, you can access the cumulative tick count of a bar, but unfortunately there's method to access the collection / grouping of trades in this bar - you could custom code this for realtime use either in the OnBarUpdate() or by accessing the Level 1 data directly in OnMarketDate().

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    Sorry, I don't follow you jon, you can access the cumulative tick count of a bar, but unfortunately there's method to access the collection / grouping of trades in this bar - you could custom code this for realtime use either in the OnBarUpdate() or by accessing the Level 1 data directly in OnMarketDate().
                    Bertrand,

                    I think I'll run the strategy with COBC = false and access the trades from OnBarUpdate or levl1 data in OnMarketData(). Is there any difference between the two approaches?

                    Also, will I be able to open a COBC=false (tick-based) strategy on any sort of Chart (Range, PointAndFigure, Volume, etc)?

                    Much appreciated!

                    Comment


                      #11
                      1. No real difference for your requirements I would think.

                      2. Yes, you can use COBC=false on any type of chart.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        1. No real difference for your requirements I would think.

                        2. Yes, you can use COBC=false on any type of chart.

                        Josh,

                        Thanks! I created the strategy using OnMarketData and with COBC=true and it works like a charm. Now I want to backtest this strategy. However, the backtest shows no trades. When I run the strategy using Market Replay, I get many trades per day.

                        Does the Strategy Analyzer not work with OnMarketData-based strategies?

                        thanks

                        Comment


                          #13
                          Hi Jon, correct this is expected, as the OnMarketData() is not available on historical data unfortunately (realtime and market replay only).

                          Comment


                            #14
                            Originally posted by NinjaTrader_Bertrand View Post
                            Hi Jon, correct this is expected, as the OnMarketData() is not available on historical data unfortunately (realtime and market replay only).
                            Bertrand,

                            Then I'm in a bit of a pickle. I don't mind that the BackTester needs to run with COBC=true, but then how do I access the ticks within a 1-second "bar"? My LIVE version will use the OnMarketData, however since I cannot use this with the Strategy Analyzer, what do I do?

                            Can I add a 1-tick period to my strategy and check BarsInProgress == 1 (my newly added DataSeries). Can I process ticks in this fashion using Strategy Analyzer?

                            thanks!

                            Comment


                              #15
                              Jon, unfortunately this will not work, as you would not have subsecond timestamp access for the trade grouping.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              649 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              576 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X