Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily data from intraday indicator

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

    Daily data from intraday indicator

    My question is simple, I want to draw a daily SMA on a 5 tick range chart.
    NT7 has multi timeframe support, so what im doing is:

    Initialize()
    {
    Add(PeriodType.Day, 1);
    }

    The problem is that I want to calculate 100 days or 200 days SMA but only loading 5 days of intraday chart, apparently NT7 only provides data for 5 days (the time frame of the intraday setting) and is not very usefull...

    Is there any official way to do this on NT7 ? because i dont want to use the hack of "Data.Bars.GetBars"

    Thanks


    #2
    Some suggestions

    (1) With NT7 you can easily use 300 days of intraday data, there is no limitation to 5 days, you just need to change the data series setting

    (2) A SMA is a bit difficult to code, because you need to know the value that is added as well as the value that drops out 100 days ago. For an EMA it is simpler as it is calculated via a recursive method. When the session starts (check via Bars.FirstBarOfSession) you would just need to identify yesterday's close (Close[1]) and calculate the new value of the EMA.

    (3) If you want a 200 day SMA on a tick chart with a lookback period of 5 days, this is possible, but you would need to load the necessary daily data via a separate system thread. You can take the model of the NinjaTrader pivots indicator, but this indicator only loads daily data for the lookback period of the chart. If you want to load daily data exceeding the lookback period of the chart this is well possible, but you would need to modify the code.

    (4) Maybe you can convince me to code this.

    Comment


      #3
      Thanks for response, yes, i dont want to load 200 days of tick data because its memory intensive and not necessary... I will need to load day data separately via Data.Bars.GetBars, but this is very ugly.
      You need to consider this feature for NT7 to add another argument on the Add method, so you can provide the ammount of bars you want to load on that timeframe... the chart will use the main dataseries only for display, but still calling OnBarUpdate for the other dataseries..... so for example in this scheme you get called at first 195 times of OnBarUpdate for the daily data and then the OnBarUpdate of tick and daily data mixed like now.
      Another option is to add a feature that a DataSeries added via the gui have a flag to dont plot on the chart, so its just used for calculations, I saw that via the gui you can say how many days you want to load, so this is ok...

      Well here is my code of a "different timeframe" SMA indicator, the sma calculation is ok i tried it with minutes and its working nice.
      If you know how to add the daily data and modify this code will be nice.

      An important requirement is that the daily bar data is requested from the data provider and not being calculated from the tick data, this always ends with different values and errors in calculations.
      Attached Files

      Comment


        #4
        stormze, thank you for providing that little code sample and for the suggestion. I'll forward it along to the appropriate people. In the meantime, I'll leave this ticket open for tomorrow and if anyone else has any ideas they'll chime in. Also, maybe some community members have done something like this and could help you out.
        AustinNinjaTrader Customer Service

        Comment


          #5
          I think this is not possible, but there are two options:

          (1) Go the ugly way and load daily data separately, this will work.

          (2) Just cheat a bit:

          Open a tick chart. Add a second data series with daily data to this chart. Apply the default SMA indicator to the daily data series. Make sure you set CalculateOnBarClose to "False". Now change the panel for your daily data series and the indicator: Put them both on panel 1. During the last step you can change the candle colours of your daily data to transparent. This makes the daily candles disappear, but the SMA remains.

          Only problem here. If there are not at least 2 transparent candles on the chart, the indicator will not be displayed, LOL. So the clean solution is the ugly one, load the daily bars.

          Maybe the NinjaTrader Guys have a better suggestion, I don't.

          Comment


            #6
            An aditional thing about my script, I recently checked it with CL 06-10 contract, 30 days of tick data, provider IQFeed and SMA value is not correct, parameters are the default ones SMA50 on 15min, I compared it to other software and there is a big difference of about $1...

            The code is correct, it seems values are ok until 5/6, tryed reloading data but same results, both software uses same provider, seems like a bug in NT7...

            Tnx Harry by your input btw

            Comment


              #7
              stormze,

              Can you please clarify what you mean by 30 days of tick data and then SMA50 on 15min? Is this being run on a tick chart or a 15min chart? Also, what are your merge settings and the session template being used? Indicators are dependent on the data they use to calculate so these would be important for the calculations.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Main DataSeries is 5 range ticks data and I'm using 30 days back... then from my indicator I'm adding a second dataseries of 15min and I'm trying to draw a SMA50 with the 15min as input, this SMA should be drawn on the ticks price pannel (check the code I uploaded)
                Session template I'm using is Default 24/7 and merge settings are the default ones, I didnt touched anything on this...
                The problems are two:

                1) For some reason the result of this SMA is not correct
                2) I cant specify how many bars to load when calling Add on Initialize

                Comment


                  #9
                  stormze,

                  Your code is not the same as the SMA indicator's code. You will need to check fidelity for that code. I suggest you simplify things and get things working on one time frame first.

                  If you want to set the SMA to use the secondary time frame you can do this instead:

                  Code:
                  if(BarsInProgress == 0 )
                  {
                       if (CurrentBarArray[0] > 0 && CurrentBarArray[1] > 0)
                            Value.Set(SMA(Closes[1], 50)[0]);
                  }
                  When you use this and open a 15 minute chart on the side with the same number of days back as your range chart and add a 50 period SMA onto it you will see exactly the same values as you see by the plot.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks I tryed your code but I got same results.
                    I investigated this further and what I found is that, for some reason, I had no price data for day 5-7, after closing NT7 and opening it again then reload all historical data, prices are complete and SMA seems good now...
                    Pls check if you can reproduce it from your side.....

                    It would be nice also that if you get some error from the data provider, let it show on the screen instead of silently ignore and record no prices on that chunk.

                    Did you added that feature request of extending Add method so you can provide the ammount of bars you want to load ? thanks in advance

                    Comment


                      #11
                      I guess I found the problem, tryed with other symbol, ES this time.

                      It seems that the bug is that when you select reaload all historical data from a chart, it doesnt load the additional timeframes that indicators uses on the chart. In this case 15min bars are NOT reloaded.
                      Note that this 15min timeframe is added from script with Add, chart has just one DataSeries showed on the gui.
                      Hope you can check and fix this on the future build...

                      Comment


                        #12
                        stormze,

                        Please provide exact steps as to how you are qualifying that the minute bars are not reloaded. Thank you.

                        There were no gaps on my end and so it is unreproducible. Should you have gaps in data you would have different SMA values and this would be expected though.

                        Your suggestion for the Add method has already been noted on our feedback list. Thank you.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Try this to reproduce:
                          Modify by hand on the DB some of the values for minute price data, then do reload all historical data from a tick chart that has an indicator with a minute timeframe added from scripting... you should note that minute data are not reloaded...

                          Comment


                            #14
                            We will get back to you at a later point in time. Thank you.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              stormze,

                              I have discussed this with development and it is expected behavior. You will need to open a chart with your secondary Bar series and then do a reload with that open to get that series reloaded.

                              Thank you for the suggestion though. I have added it to our feedback list.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              606 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              353 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
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              561 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X