Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart data is not the same as in Print(...)

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

    Chart data is not the same as in Print(...)

    During back test I print "day before" high/low data for "ES 03-13" like this:
    Print(Time[0].Date.ToString("d") + " " + CurrentDayOHL().CurrentOpen[0] + " " +
    Bars.GetDayBar(1).Low + " " + Bars.GetDayBar(1).High);

    Then I created a daily chart for "ES 03-13". The values are completely different!
    I do notice in "Data Box" on the chart, each "date" has time of "16:15". Why?? Does this mean that it considers "16:15" "close" time? This would explain this complete discrepancy in prices. How do I fix the chart to accurately show daily prices? Chart template? (there is none to select from)

    #2
    Mark,

    The way this works for you may depend on data provider.

    Can you please clarify who you connect to for data?

    Can you give me an example of the results you're seeing when you compare?
    MatthewNinjaTrader Product Management

    Comment


      #3
      I use MB Trading. Data for chart and backtest comes from the SAME place - it must be the same!
      I just noticed that values are "correct" but for a different date. For example,"Print" (Y is yesterday):
      date Y-low Y-hi
      11/21/2012 1370.75 1383.5
      11/22/2012 1382.5 1387.5
      11/25/2012 1381 1401.25
      11/26/2012 1388.75 1398.75
      11/27/2012 1389.25 1401.5

      Chart:
      11/21/2012 1370.75 1383.5
      11/22/2012 (no data)
      11/23/2012 1381 1401.25
      11/26/2012 1388.75 1398.75
      11/27/2012 1389.25 1401.5

      I see the problem: I calc Bars.GetDayBar(1).Low and Bars.GetDayBar(1).High
      on the Bars.FirstBarOfSession. Apparently, NT is giving me TODAY's data instead of yesterday's!
      How to I work around this problem?

      Comment


        #4
        Can you provide a snippet of the code you're using?

        I've checked this on my end and do not see this behavior. For example on the ES 03-13, on the 1/15/2012, I get the following result which matches my chart:

        1/14/2013 3:15:00 PM High Bar : 1471.25
        1/14/2013 3:15:00 PM Low Bar : 1460.25
        MatthewNinjaTrader Product Management

        Comment


          #5
          I've attached (almost complete) strategy.
          The code you want to see is:
          Print(Time[0].Date.ToString("d") + " " + CurrentDayOHL().CurrentOpen[0] + " " +
          Bars.GetDayBar(1).Low + " " + Bars.GetDayBar(1).High);
          Attached Files

          Comment


            #6
            Originally posted by MarkZ View Post
            I use MB Trading. Data for chart and backtest comes from the SAME place - it must be the same!
            I just noticed that values are "correct" but for a different date. For example,"Print" (Y is yesterday):
            date Y-low Y-hi
            11/21/2012 1370.75 1383.5
            11/22/2012 1382.5 1387.5
            11/25/2012 1381 1401.25
            11/26/2012 1388.75 1398.75
            11/27/2012 1389.25 1401.5

            Chart:
            11/21/2012 1370.75 1383.5
            11/22/2012 (no data)
            11/23/2012 1381 1401.25
            11/26/2012 1388.75 1398.75
            11/27/2012 1389.25 1401.5

            I see the problem: I calc Bars.GetDayBar(1).Low and Bars.GetDayBar(1).High
            on the Bars.FirstBarOfSession. Apparently, NT is giving me TODAY's data instead of yesterday's!
            How to I work around this problem?
            You are keying off of FirstBarOfSession. Your results will, therefore, depend on the session template that you are using.

            Comment


              #7
              chart data slightly off vs. backtest data

              I'm using template "CME US Index Futures RTH" during both backtest using "ES 03-13" and also looking at the chart "Data Box". I've noticed that the day prices (open/high/low) are slightly different (chart vs. "Print").
              I use CurrentDayOHL().CurrentOpen[0] - open for current day (computed in OnBarUpdate() if (Bars.FirstBarOfSession) is true).
              I also print:
              Bars.GetDayBar(1).Close - previous trade day close
              Bars.GetDayBar(1).High - previous trade day high
              Bars.GetDayBar(1).Low- previous trade day low

              These prices differ from what I see in the chart "Data Box" (same template as above).
              All this is for "ES 03-13".
              For examplen 1/21/13, open in "Data Box" shows 1483.50,
              CurrentDayOHL().CurrentOpen[0] on Bars.FirstBarOfSession) of 1/21/13 is 1480.00.
              ...(and many others). What is wrong?

              Comment


                #8
                Originally posted by MarkZ View Post
                I'm using template "CME US Index Futures RTH" during both backtest using "ES 03-13" and also looking at the chart "Data Box". I've noticed that the day prices (open/high/low) are slightly different (chart vs. "Print").
                I use CurrentDayOHL().CurrentOpen[0] - open for current day (computed in OnBarUpdate() if (Bars.FirstBarOfSession) is true).
                I also print:
                Bars.GetDayBar(1).Close - previous trade day close
                Bars.GetDayBar(1).High - previous trade day high
                Bars.GetDayBar(1).Low- previous trade day low

                These prices differ from what I see in the chart "Data Box" (same template as above).
                All this is for "ES 03-13".
                For examplen 1/21/13, open in "Data Box" shows 1483.50,
                CurrentDayOHL().CurrentOpen[0] on Bars.FirstBarOfSession) of 1/21/13 is 1480.00.
                ...(and many others). What is wrong?
                What time frame is the chart?

                Comment


                  #9
                  Is it just the 21st that you're seeing this? Or do you have issues with other dates as well?

                  I'm not able to recreate your scenario and I'm trying to understand if this may be related to the holiday session on that day.

                  I look forward to assisting you further.
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    any time frame - for example 1/1/13 - 1/28/13

                    Comment


                      #11
                      NO, not only on 1/21/13 - this was just one concrete example.
                      PLEASE READ my post #7 "chart data slightly off vs. backtest data"

                      Comment


                        #12
                        Originally posted by MarkZ View Post
                        any time frame - for example 1/1/13 - 1/28/13
                        Not "Time Span", "time frame".

                        Comment


                          #13
                          we are only looking at DAY'S "open price" - how would time span affect it?
                          I tried 1 min, 5 min...

                          Comment


                            #14
                            GetDayBar is a virtual bar built off of intraday data. If you'r trying to get the HLC from a previous RTH session, I'd suggest using the PriorDayOHLC method:



                            This method gives you better control over the exact session you're testing against and it is pulling a single bars index.

                            If you would prefer to continue to use GetDayBar, I'd be happy to help you work this out, but there are some tricks to working with this property. From your txt file you included, it was a bit hard to read, but I don't see where you're checking that the day bar actually exists.

                            I'd suggest adding these null checks as per our Help Guide:

                            MatthewNinjaTrader Product Management

                            Comment


                              #15
                              Originally posted by MarkZ View Post
                              we are only looking at DAY'S "open price" - how would time span affect it?
                              I tried 1 min, 5 min...
                              Using this code:
                              Code:
                               
                                      #region Variables
                                private double OpenFBOS;
                                private DateTime TimeFBOS;
                                private double BarOpen;  
                                      #endregion
                              Code:
                                     protected override void Initialize()
                                      {
                                          Overlay    = true;
                                      }
                              Code:
                               
                                      protected override void OnBarUpdate()
                                      {
                                 if (Bars.FirstBarOfSession) 
                                 {
                                  Print(null); 
                                  Print("CurrentBar: " + CurrentBar);
                               
                                   OpenFBOS = CurrentDayOHL().CurrentOpen[0];
                                   TimeFBOS = Time[0];
                                   BarOpen  = Open[0];
                               
                                  Print("Open-FBOS: " + OpenFBOS);
                                  Print("Time-FBOS: " + TimeFBOS);
                                  Print("BarOpen: " + BarOpen);
                                 }
                               
                                      }
                              Here are the results in the Output Window:
                              CurrentBar: 405
                              Open-FBOS: 1479.75
                              Time-FBOS: 1/21/2013 9:35:00 AM
                              BarOpen: 1479.75
                              The attached picture shows the Data Box. The values look the same to me.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by WHICKED, Today, 12:45 PM
                              2 responses
                              16 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by GussJ, 03-04-2020, 03:11 PM
                              15 responses
                              3,272 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Taddypole  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              4 responses
                              51 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Working...
                              X