No announcement yet.

Partner 728x90


Indicator that calculate in different chartime

  • Filter
  • Time
  • Show
Clear All
new posts

    Indicator that calculate in different chartime


    I want to create an indicator that show data in a chart but calculate in other charttime different to the time of the chart where is showed.

    For example: Show an indicator lines in a 5 minute chart, but calculate and show the results for 30 minutes charttime

    I coded it in NT7 as:

    (In the Initialize function...)

    Add(PeriodType.Minute, 30);
    but doesnt work in last NT7 versions... why?

    Now, I want to code it in NT8. Who could I do it?

    Thank you.

    Last edited by ninjo; 01-27-2019, 12:44 PM.

    Hello ninjo,

    NinjaTrader 8 uses AddDataSeries().

    Below is a link to the help guide.

    Also below is a link to the reference sample on intra-bar granularity that uses AddDataSeries().

    As well as a link to the code breaking changes where you can search for a method or property that was documented for NinjaTrader 7 to find the NinjaTrader 8 equivalent in the filter results section.
    Chelsea B.NinjaTrader Customer Service


      Thank you ChelseaB.

      I programmed and indicator fro NT 7 in 2015 that shows drwas of other charttime in the principal chart. From las 7.0.1000.39 (or earlier,I am not sure) NT 7 version doesnt work correctly.

      Whats happended? Could you restore it in the next update please?

      Last edited by ninjo; 02-11-2019, 05:52 AM.


        Maybe could I download a previous version of NT 7 where it works.
        Have you a website with a historical NT 7 versions links to download ?
        The Setup.exe only install the last NT 7 Version....

        Thank you


          Hello, *ninjo*.
          When You say "but doesnt work in last NT7 versions" - what exactly do You mean?
          Did indicator plot just anything on the chart?
          Do You see any error messages in Output Window or Log tab of control center?
          NinjaTrader Ecosystem Vendor - fx.practic


            Hello fx.practic,

            My indicator consists in showing some graphical indications based on a time variable sent.
            I declared the next code in Initialize() function for it

             Add(PeriodType.Minute, myChartTimeVar);
            Everything worked correctly until I installed the 7.0.1000.39 NT7 update. Neither does it work in the last 7.0.1000.40 NT7 update

            I do not remember which was the last one that worked correctly ... maybe 7.0.1000.37 ? I dont kwno.
            I dont modified the code of my indicator.

            I would like to have a list of release.exes to test which of them works

            Here the release notes. But not the software link....

            I am not sure, but maybe the problem occurred when fixing this

            NinjaTrader Version 7.0.1000.38 Production Release - March 7, 2018
            Fixed 5080 Indicators Removed 'Plot current value only' from CurrentDayOHL as it is a duplicate function of changing the plots to Horizontal lines

            Thank you
            Last edited by ninjo; 02-11-2019, 08:32 AM.


              Hello ninjo,

              Is there an error message we can assist with resolving?

              Please write an email to platformsupport [at] ninjatrader [dot] com. I can provide you with the installer for 7.0.1000.32 for testing purposes. However, I this would only be for testing to find what has changed in NinjaTrader and would not be to supply you with an unsupported version for use.

              In the email please include a link to this forum thread.
              Chelsea B.NinjaTrader Customer Service


                Its ok ChelseaB. I sent it.

                If you send a list of releases .exes I cant try from the 38 to 32 and find what was the last where works correctly.

                Thank you


                  Hi ChelseaB. I solved the problem with the NT 7 indicator. Now works correclty. Thak you for your excellent support.

                  Now, I want to use two instances of the EMA indicator with differents times calculations in the same chart.

                  For ex. If the principal time of the chart is 5 minutes, I want to show the 5 EMA calculation, and the 60 chart EMA calculation but in the same 5 minute chart.

                  Could you help me please?

                  Thank you.!


                    Hello ninjo,

                    You can do this manually on the chart by adding a series in the Data Series window and using this for the input series of the indicator.

                    Or in code, you can do this by adding a series and supplying the series as the input series parameter to the indicator call.
                    Chelsea B.NinjaTrader Customer Service


                      Hi ChelseaB

                      I am trying and works correctly when I call SMA, EMA, VOL, and others NT indicators, but doesnt work when i call my own indicator and I cant discover my error.

                      The output window launch this message:

                      "Error on calling 'OnBarUpdate' method on bar 1117: Index was outside the bounds of the array."

                      Please, could you help me to understand and solve it?

                      Thank you
                      Last edited by ninjo; 02-18-2019, 05:18 AM.


                        Hello ninjo,

                        With the error:
                        "Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart"
                        This message indicates an invalid index was used.

                        As one example, calling Close[1] when CurrentBar is 0 (the very first bar) will cause this error.
                        The reason for this is because there will not be a bar ago; essentially there is not enough data at bar 0 look back one bar.
                        The script will start from the far left of the chart at the very beginning where the CurrentBar will equal 0 and then start working to the right, calling each bar for OnBarUpdate();
                        In this specific example, it would be needed to wait for the second bar to be built (from all series if there are multiple series added), to ensure that you have enough data to call a index 1 bar ago.
                        This is especially important when multiple series are added to a single script as the data for all series may not start at the same time. Each series will need a check that CurrentBars[series index] is greater than the largest barsAgo index used.

                        Below is a link to the help guide on this specific example of an indexing error.

                        Also, below are links to the help guide on CurrentBar and CurrentBars.

                        Indexing errors can also occur when using an invalid index with arrays or collections.
                        Below are public links to 3rd party educational sites on arrays and index out of range errors.

                        What is the exact line of code generating the error?
                        Last edited by NinjaTrader_ChelseaB; 06-25-2020, 10:49 AM.
                        Chelsea B.NinjaTrader Customer Service


                          Yes I understand.
                          I am coding this in both indicators, but the error still..

                          protected override void OnBarUpdate()
                                  if(CurrentBar < Count-2 ) return;

                          The error line is 1117... but my script only have 176 lines )

                          EDITED: Excused me, the error is in 1117 bar. I am goin to look for


                            Hello ninjo,

                            The code you have provided is not the causing the error.

                            If you comment out all other logic in OnBarUpdate except for that one line, does the error still occur?

                            Are you using prints to figure out which line of code has the error?

                            As in, adding prints on every other line to see which print is the last to print before the error occurs?
                            Chelsea B.NinjaTrader Customer Service


                              Hi ChelseaB,
                              I attached a simple code in a .cs

                              For example I want to show in my chart, the value of the VOL indicator

                              It returned: "Indicator 'ExampleAddSeries': Error on calling 'OnBarUpdate' method on bar 1952: Index was outside the bounds of the array."
                              Attached Files
                              Last edited by ninjo; 02-19-2019, 10:10 AM.


                              Latest Posts


                              Topics Statistics Last Post
                              Started by ghiasi123, Today, 10:17 AM
                              1 response
                              Last Post NinjaTrader_Zachary  
                              Started by demarcog, Today, 09:50 AM
                              1 response
                              Last Post NinjaTrader_ChrisL  
                              Started by Martin89, Today, 09:53 AM
                              0 responses
                              Last Post Martin89  
                              Started by timmbbo, Today, 09:10 AM
                              1 response
                              Last Post NinjaTrader_Manfred  
                              Started by space_trader, 11-26-2020, 05:06 AM
                              2 responses
                              1 like
                              Last Post klaus w
                              by klaus w