Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time Frame Strategy & CalculateOnBarClose = false in strategy analyzer

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

    Multi Time Frame Strategy & CalculateOnBarClose = false in strategy analyzer

    The value of the indicators I'm using in a multi time frame strategy don't seen to be updating tick by tick like I expect when using CalculateOnBarClose = false. Am I doing something wrong or is this a bug in NT7 beta 15? Notice that in the output that each time the 1M MACD Diff is printed it changes, as expected since I'm calling print every minute. The 5 minute however only changes every 5 minutes, as if it's only updating on bar close and not tick by tick. Is this expected or is this a bug? Is there another way to get the current value of this indicator for the 5M bars (where I would see it change every minute)?

    Thanks,
    Tom

    Code:
            protected override void Initialize()
            {
                Print("--------------------------Initialize()-----------------------------");
                CalculateOnBarClose = false;
                Add(PeriodType.Minute, 1);
                Add(PeriodType.Minute, 5);                    
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                //If this is not the 1M series, return
                if (BarsInProgress != 1) {return;}
                
                //Print the current time
                Print(Time[0].ToString("F"));
                
                Print("--> 1M MACD.Diff: "+ MACD(BarsArray[1],12, 26, 9).Diff[0].ToString());
                Print("--> 5M MACD.Diff: "+ MACD(BarsArray[2],12, 26, 9).Diff[0].ToString());            
            }
    Output from my test:

    Friday, April 30, 2010 1:49:00 PM
    --> 1M MACD.Diff: -5.9918578124306E-06
    --> 5M MACD.Diff: -0.000179353176249744
    Friday, April 30, 2010 1:50:00 PM
    --> 1M MACD.Diff: 1.26028004595479E-06
    --> 5M MACD.Diff: -0.000183011871550686
    Friday, April 30, 2010 1:51:00 PM
    --> 1M MACD.Diff: 1.39170413466062E-05
    --> 5M MACD.Diff: -0.000183011871550686
    Friday, April 30, 2010 1:52:00 PM
    --> 1M MACD.Diff: 1.01208086765815E-05
    --> 5M MACD.Diff: -0.000183011871550686
    Friday, April 30, 2010 1:53:00 PM
    --> 1M MACD.Diff: 2.17151610795235E-05
    --> 5M MACD.Diff: -0.000183011871550686
    Friday, April 30, 2010 1:54:00 PM
    --> 1M MACD.Diff: -2.37361898739995E-06
    --> 5M MACD.Diff: -0.000183011871550686
    Friday, April 30, 2010 1:55:00 PM
    --> 1M MACD.Diff: -2.88734690328843E-06
    --> 5M MACD.Diff: -0.000190391873955962
    Friday, April 30, 2010 1:56:00 PM
    --> 1M MACD.Diff: 5.0270560763474E-06
    --> 5M MACD.Diff: -0.000190391873955962
    Friday, April 30, 2010 1:57:00 PM
    --> 1M MACD.Diff: -1.41111274471213E-05
    --> 5M MACD.Diff: -0.000190391873955962
    Friday, April 30, 2010 1:58:00 PM
    --> 1M MACD.Diff: -1.72610988678615E-05
    --> 5M MACD.Diff: -0.000190391873955962
    Friday, April 30, 2010 1:59:00 PM
    --> 1M MACD.Diff: -4.20943323515932E-05
    --> 5M MACD.Diff: -0.000190391873955962
    Friday, April 30, 2010 2:00:00 PM
    --> 1M MACD.Diff: -5.99751746444079E-05
    --> 5M MACD.Diff: -0.000231192337955555

    #2
    tomtom,

    When you are backtesting in the Strategy Analyzer strategies are always run with CalculateOnBarClose = true regardless of your setting. This is because you do not have intrabar information and just snapshot, end of bar information.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Yes, I'm fine with individual ticks not going through, but the strategy is already running OnBarUpdate every minute to update the 1M bars, how come that same process can't also update update the 5M bars? Wouldn't that make the strategy analyzer behave closer to real time and be relatively simple to do? Something like: If CalculateOnBarClose = false, then for each OnBarUpdate, update the OHLC for every bar object. In this case, that would mean that every 1 minute the 1M and 5M bars would be updated and all indicators would reflect the current value as of the close of the 1M bar.

      Thanks,
      Tom

      Comment


        #4
        tomtom,

        As mentioned, when you are using the Strategy Analyzer the strategies are always run with CalculateOnBarClose = true. Reason 1m does not update 5m is because you don't have snapshot data 5 times for the 5m. You have one set of OHLC for the 5m. There is no transposing the 1m series onto that 5m series.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Is this a feature you see any value in adding? It seems relatively easy to add a setting for or use the CalculateOnBarClose setting for.

          Thanks,
          Tom

          Comment


            #6
            Tom,

            It is not a trivial task to add this. It is a completely different concept. Thank you for the suggestion. I have added it to our feedback list.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your help. Since what I wanted to do won't work, is there another way you can think of to get around this, or do I have to test on live data? I also tried changing the 5M Highs and Lows arrays every time the 1M changed, but it tells me they are read only.

              Thanks,
              Tom

              Comment


                #8
                Please see here. Sequencing is important: http://www.ninjatrader-support2.com/...ead.php?t=6652
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Barry Milan, Yesterday, 10:35 PM
                5 responses
                16 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by DanielSanMartin, Yesterday, 02:37 PM
                2 responses
                13 views
                0 likes
                Last Post DanielSanMartin  
                Started by DJ888, 04-16-2024, 06:09 PM
                4 responses
                13 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by terofs, Today, 04:18 PM
                0 responses
                11 views
                0 likes
                Last Post terofs
                by terofs
                 
                Started by nandhumca, Today, 03:41 PM
                0 responses
                8 views
                0 likes
                Last Post nandhumca  
                Working...
                X