• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator that calculate in different chartime

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

    Indicator that calculate in different chartime

    Hello,

    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...)

    Code:
    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, 11:44 AM.

    #2
    Hello ninjo,

    NinjaTrader 8 uses AddDataSeries().

    Below is a link to the help guide.
    https://ninjatrader.com/support/help...dataseries.htm

    Also below is a link to the reference sample on intra-bar granularity that uses AddDataSeries().
    https://ninjatrader.com/support/help...ipt_strate.htm

    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.
    https://ninjatrader.com/support/help...ng_changes.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      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, 04:52 AM.

      Comment


        #4
        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

        Comment


          #5
          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?

          Comment


            #6
            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

            Code:
             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....
            https://ninjatrader.com/support/help...ease_notes.htm


            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, 07:32 AM.

            Comment


              #7
              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

              Comment


                #8
                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

                Comment


                  #9
                  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.!


                  Comment


                    #10
                    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.
                    https://youtu.be/XRGxiO3XW-k

                    Or in code, you can do this by adding a series and supplying the series as the input series parameter to the indicator call.
                    https://ninjatrader.com/support/help.../barsarray.htm
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      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, 04:18 AM.

                      Comment


                        #12
                        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.

                        Below is a link to the help guide on this specific example of an indexing error.
                        https://ninjatrader.com/support/help...nough_bars.htm

                        Also, below are links to the help guide on CurrentBar and CurrentBars.
                        http://ninjatrader.com/support/helpG...currentbar.htm
                        https://ninjatrader.com/support/help...urrentbars.htm

                        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.
                        https://www.dotnetperls.com/array


                        What is the exact line of code generating the error?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


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


                          Code:
                          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

                          Comment


                            #14
                            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

                            Comment


                              #15
                              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, 09:10 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by TikDaddy, Today, 02:08 PM
                              2 responses
                              7 views
                              0 likes
                              Last Post NinjaTrader_JoshG  
                              Started by Brillo, Today, 01:52 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Jim  
                              Started by TazoTodua, 02-09-2018, 08:40 AM
                              10 responses
                              880 views
                              0 likes
                              Last Post NinjaTrader_JoshG  
                              Started by TazoTodua, Yesterday, 04:35 AM
                              6 responses
                              18 views
                              0 likes
                              Last Post eDanny
                              by eDanny
                               
                              Started by MattP, Today, 12:25 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_PatrickG  
                              Working...
                              X