Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Beta 21 Wrong daily values in Range Bar chart

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

    Beta 21 Wrong daily values in Range Bar chart

    I am not sure if this is a bug. I did a simple test script where I am using a TF 12-10 5 range chart. All I am trying to do is display a horizontal line of the 200 day simple MA from daily data in my range bar chart.

    protected override void Initialize()
    {
    Add(PeriodType.Day,1);
    }
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1){
    DrawHorizontalLine("line",SMA(200)[0],Color.Red);
    Print(Time[0]+" "+SMA(200)[0]+" "+Close[0]);
    }
    }

    When I load this script and it prints the daily values, it gives me one 3 days of values since my chart window is only set for 3 days. Yet it will not draw the line.

    The output as of today is
    9/9/2010 12:00:00 AM 629.9 632.3
    9/10/2010 12:00:00 AM 630.366666666667 631.3
    9/11/2010 12:00:00 AM 631.15 633.5

    Where it seems to be jumping to tomorrow,and the SMA(200) value according to a daily chart is around 640, not 630.3666 for today. It is also wrong for the other days.

    -Alex

    #2
    AlexJetski,

    The issue is simply you are not loading enough bars back. If you want a 200 day SMA you really need to load at least 200 days. Your chart of 3 days back would definitely not be sufficient enough to properly calculate a 200 day SMA.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply Josh.

      I can see where it makes sense to load 200 days. However, this is not possible in a 5range chart. If I create a new TF 12-10 chart 5r for 200 days, it will only fetch data from sept 2 onwards.

      So is there a way to have daily or even weekly data available in a range bar chart?

      Comment


        #4
        Ok I finally got it fetch enough data for both a 5range and a 5min chart 200 days back. Both give me an sma 200 value of 652.2. And a daily chart of TF value is 640.3. The numbers are not even close to coinciding.

        Comment


          #5
          AlexJetski, I just created a script to test this out and everything looks find here on my end. I put the indicator to calculate the 200 day SMA on a 5 minute chart, and it gave a result which correlates with a 200 period SMA on a daily chart.
          Attached Files
          AustinNinjaTrader Customer Service

          Comment


            #6
            Hi Austin,

            Thanks for testing it. I can see from your picture that it matches the daily perfectly. I can't seem to make it work in my end. Can you please try your setup with 5range TF. I am attaching my test script and also a picture of what I am seeing on both a 30min and 5r charts. I can't get the numbers to match up. Unsure how to proceed.

            thanks for the help,

            Alex
            Attached Files

            Comment


              #7
              AlexJetski, I am also not getting the correct values when using a 5 range chart. We will take a look at this starting on Monday.
              Attached Files
              AustinNinjaTrader Customer Service

              Comment


                #8
                Alex,

                This would be highly dependent on your session template in use and data provider. Intraday data like range would build data based on whatever session template you selected while daily data would contain data either on a RTH basis or an ETH basis depending on what the data provider wants to do. These factors would need to be all aligned in order to see similar values, but even then, some data provider's intraday data is simply slightly different than their daily data and discrepancies can still arise.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Josh,

                  Sorry your answer still does not make sense. If I look at the mydocs/NT7/db/day folder, stored daily values are used to plot a daily chart. So why would a range bar chart not access this information and give the exact answer as a daily chart would? From what you are telling me, range bar charts the way I have them set to 24/7, would generate the daily values by another method, based on data feed and not use the day folder at all. Is the that a true interpretation.

                  -Alex

                  Comment


                    #10
                    Alex,

                    Because you have not pulled enough daily data. A range chart loads maybe 3 days of data by default. This is no where near enough to get an accurate SMA(200) off a daily series. Trying to calculate SMA(200) with only 3 days of data will absolutely be inaccurate. You are missing 197 data points for that calculation. The value you get returned is effectively SMA(3) since you only have 3 data points.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Josh,

                      Ok totally understood now. Then perhaps this suggestion to wish list of add ones might be considered later.

                      When you have a

                      Add(PeriodType.Day,1,"option to go back X days back on this BarsArray only")

                      This way, you won't need to load 200 days and have a chart with data points that are not needed.

                      -Alex

                      Comment


                        #12
                        Glad we are now on the same page. Thank you for the suggestion. I have added it to our feedback list.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Human#102, Yesterday, 09:54 AM
                        2 responses
                        7 views
                        0 likes
                        Last Post Human#102  
                        Started by Patlpp, 08-16-2021, 03:10 PM
                        10 responses
                        498 views
                        0 likes
                        Last Post Joerg
                        by Joerg
                         
                        Started by AdamDJ8, 05-07-2024, 09:18 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post -=Edge=-  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        46 responses
                        4,103 views
                        3 likes
                        Last Post tradgrad  
                        Started by usasugardefender, Today, 01:42 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post usasugardefender  
                        Working...
                        X