Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi time frame strategy

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

    Multi time frame strategy

    Hi

    I would like to ask if it is possible to create a strategy, whith 2 diferent time bases, with the higher time frame making historical calculations for 10 days, and the small time frame only 1 day.

    Imagine a strategy that have um time frame with 2304 ticks and another time frame with 1 tick, for tick to tick calculations

    When I initilize the time frames, this will make the OnBarUpdate event to be called every tick, generating a lot of interrupts and extend the calculations to several seconds for each indicator using this method

    I would only to make calculations on a tick to tick base on the last day, so I would like to have historical calculations of 10 days on the 2304 ticks chart and only the tick by tick calculations on the last day.

    If this is not possible it is possible to change the time frames after initialization.

    I could start both time frames at 2304 and then when I get something like Time[0].Day == DateTime.Now.Day, I switch the BarsInProgress 1 to one to one tick calculations?

    Another other ideias to workarround are also welcome.

    #2
    There doesn't really exist options to separate the date loaded depending on the series. The date is specified in the strategy settings and will apply to all series.

    The 'best practice" here depend on your goals. Are you looking to improve performance backtesting or during real time? Once the values are calculated for the historical period, the strategy doesn't need to go back and calculate again.
    Last edited by NinjaTrader_RyanM1; 01-26-2011, 04:36 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      The ideia is to decrease the time that the indicators take to load. When I start the workspace with all indicators, it take more the 2 minutes to load everything. Due to heavy processing, during this period the feed data is not received correctly.

      If I do not start the workspace, before the openning bell, I will miss some data from the feed, and wait more than one minute to have the charts again when I refresh one of the time bases is very bad.

      All the indicators use the same process of calculations, and I have 2 different indicators for each chart. If I open 4 different time bases I will get a lot o repeated calculations

      Another possibility, was to have only one indicator to make the calculations, and the others receive the tick by tick calculations. The problem is that I did not find any process to transfer information from one indicator to another in the same chart, or even worst in diferent charts.

      Comment


        #4
        I see. Thanks for the reply.

        You may be able to set indicator values conditionally then, as you propose in your first post.

        The big drawback to this is that you'll also want to check values conditionally, as the values called historically won't be what you expect. This is also done in the indicator itself, not the strategy, which may cause issues if you're using the same indicator for both series. Most likely your best bet will be to create two different indicators for the two series.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I will explain further, in order to workaround this issue, I implement a cache process where I save the calculated values on a tick by tick base into a file.

          The when I put every thing to work, I realize the it takes more or less the same time to make the calculations or to read the values from the cache file. The problem, I believe is the fact that the OnBarUpdate is called every tick for the lowest bar in progress.

          So during cache reading, I do not need tick by tick calculations, but because in the last day I would like to make the calcultions in order the have seamless change between historical and real time, I need to switch to tick to tick calculations again.

          I need this because, I cannot cache until the last tick of the feed, so making the calculactions for the last day only, looks like a good comprimise.

          I was just asking if it ispossible to switch the period of the bar in progress, before I even try, because if it is not possible I will save some hours of work in order to put everthing running again.

          Comment


            #6
            Another even better solution, could be disable the OnBarUpdate() event for one Bar in Progress and activate it later. Is this possible?

            Comment


              #7
              No, there's nothing you can do to disable OnBarUpdate. You can return out of processing bar updates with return statement.

              if (BarsInProgress != 0) return;
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_RyanM View Post
                No, there's nothing you can do to disable OnBarUpdate. You can return out of processing bar updates with return statement.

                if (BarsInProgress != 0) return;
                That is the initial problem

                If I do that, a normal indicator inside um chart that takes 2 seconds to load it will take 8 seconds just by doing this

                protected override void Initialize()
                {
                Add(PeriodType.Tick, 1);
                ......

                }

                protected override void OnBarUpdate()
                {
                if (BarsInProgress != 0) return;
                .......
                }

                What I need is to change the BarsInProgress interrupt time to more than 1 tick for a specific period when I am loading the chart or even disable the OnBarUpdate event for that specific BarsInProgress and activate it later during the loading process

                Comment


                  #9
                  Unfortunately I'm not sure the exact implementation you'll need for maximum efficiency. I would review the performance tips available below for ways to reduce Ninja's resource requirements.

                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_RyanM View Post
                    Unfortunately I'm not sure the exact implementation you'll need for maximum efficiency. I would review the performance tips available below for ways to reduce Ninja's resource requirements.

                    http://www.ninjatrader.com/support/h...ance_tips2.htm
                    I just comparing two source codes, with the modification of adding another time frame of 1 tick. I believe that I can compared results, since I did not change anything else.

                    The main problem here is to know if I can change the period value of the second time frame during execution.

                    If yes, what are the variables to change. I try to access to the BarsArray and change the Period values without any luck, Any more properties?

                    Comment


                      #11
                      You could unfortunately not change the timeframe dynamically - you would need to Add() all frames needed and then direct to the barsobject as you desire for your script.

                      Comment


                        #12
                        Thanks anyway

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        630 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        364 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        105 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        566 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        568 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X