Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest output doesn't match chart

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

    Backtest output doesn't match chart

    Hi,

    It looks like my Print lines in the output window during backtesting don't match my chart values for the same indicator. The configuration for the backtest/chart is ^Tick 1 min on 7/29/2011. In the strat, I'm printing the values of EMA(320) and in the chart I'm showing the line for EMA(320) in panel 2.

    The strat excerpt showing the Print statements is:

    Code:
    		protected override void OnStartUp()
    		{
    				slowTickMA = EMA(320);
    		}
            #endregion
    		
     		#region Events
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate ()
            {
    				if (CurrentBar < 20)
            			return;
    							
    				//1 minute Tick	
    				if (BarsInProgress == 0) 
    				{
    					currentBarDateTime = Time [0].ToString ("yyyy-MM-dd HH:mm:ss");
    					Print (
    					currentBarDateTime
    					+ " slowTickMA[0]: " + slowTickMA[0]
    					);
    				}
            }
    When I run this strat in a backtest, the value in the first Print:

    2011-07-29 06:51:00 slowTickMA[0]: -547.097103583402

    When I show the data box for the chart on 7/29/2011 6:51am, the value for the EMA is: -150.

    I've attached:

    1. Document with screenshots of the backtest setup and chart setup/output
    2. Code for sample strat
    3. 1 minute data files for 7/28, 7/29 for that I assume the backtest and chart are using
    4. File showing the lines printed by the strat during the backtest from output window

    Can you tell me why there's a difference?

    Thanks!
    Attached Files
    Last edited by rkwan; 08-02-2011, 05:29 AM.

    #2
    I need to check this out later. It sounds like the strategy sessions template issue.

    I have a post I need to dig up and forward.

    Comment


      #3


      I found extra bars after 4:00pm close which are not taking into account on the chart, hence the ema's/sma's/whatever will look different (and TDA throws in extra bars over night).

      In short, the chart and the strategy are not the same until you get past your xxx bars required by your strategy.

      Comment


        #4
        Thanks for your link - I set the session for the backtest and chart to US Equities RTH.

        At 10am PT the backtest printed:

        14 2011-07-29 10:00:00 slowTickMA[0]: -163.290279144522

        and the data box on the chart at 10am PT is showing EMA(320) = -42

        I'm not sure why they don't match since the market has been open for 3.5 hours by then, especially since the time frame is 1min.

        Comment


          #5
          rkwan, as sledge correctly stated the Initialization() is different here, would you see the same difference if you gave your 320 MA more bars to catchup, so loading for example one more day of 1min historical data here?

          Thanks,
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thanks Bertrand,

            If I run the backtest and chart for July 28-29, then I get these values on July 29:

            Backtest print:
            14 2011-07-29 10:00:00 slowTickMA[0]: -41.7137360596667
            14 2011-07-29 11:00:00 slowTickMA[0]: -14.437151238035
            14 2011-07-29 12:00:00 slowTickMA[0]: -25.9828149895203

            Chart:
            10am: -46
            11am: -17
            12am: -28

            So I don't understand:

            1. Why it's not caught up after more than 320 bars (i.e. great than 5 hours 20 min)?
            2. Why the backtest is including a different number of bars in the average than the chart?

            Thanks!

            Comment


              #7
              rkwan, what NT7 release version are you using here? I was not able to reproduce on my end, please see the shot attached with your strategy and 1min TICK data from Kinetick comparing strategy print vs chart values, revealing as only difference the expected rounding the chart panel would do here.
              Attached Files
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Version # is 7.0.1000.6

                I just deleted/redownloaded data for 7/25 and 7/29 from Kinetick and print lines and chart EMA numbers match now. The data was originally from IB so maybe there was an issue there.

                Thanks again!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,609 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                16 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X