Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bug: MAX and MIN return false values on Renko bars

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

    Bug: MAX and MIN return false values on Renko bars

    I have made extensive use of the NinjaScript methods MAX and MIN and find my indicators and strategies crashing on Renko bars.

    I have traced this back to a bug of MAX and MIN that do not calculate correctly on Renko bars. The reason here is that MAX and MIN cannot handle bar types that support RemoveLastBar().

    In fact when you calculate MAX(20) on Renko bars, it sometimes returns MAX(19) instead, not taking into account Input[19], which is omitted. This leads to logical contradictions which result in crashing indicators.

    For further evidence I have attached a chart that shows an obvious miscalculation for MAX on a Renko chart. The error only occurs when MAX is applied in Calculate.OnEachTick or in Calculate.OnPriceChange. This further points to an incompatibility with RemoveLastBarSupported().

    Would you be able to update MAX and MIN with the next release please? It is crashing many of my NinjaScript applications.
    Attached Files

    #2
    Quick implementation of MAX that works with Renko bars

    Attached is a quickly coded version of the MAX indicator that works with Renko bars and other bar types that support RemoveLastBar().

    I have tested in Calculate.OnEachTick both with Renko bars and in tick replay (no Renko bars). Performance is similar to the old MAX indicator. I have added a public property that allows for accessing the exact location of the maximum that has been calculated.

    Please feel free to use it and to replace the default indicator.
    Attached Files
    Last edited by Harry; 07-31-2017, 06:24 PM.

    Comment


      #3
      Originally posted by sonia0101
      you have a well rounded user with goblets of knowledge and yet no response as of yet to a pointed out LOBT flaw.
      utterly amazing
      thanks Harry you seem to care which is more that I can say for the Dev TM. lol but not funny
      This is not a big deal. It is just a minor bug in an indicator that can be fixed in an hour. The problem here is that the logic of exotic bar types has changed and that they are processed several times when the indicator is set to Calculate.OnEachTick.

      This requires that all NinjaTrader 7 indicators are checked and adapted accordingly. For MAX and MIN this has not beend tested and therefore it cannot handle the new logic. This is an easy fix,

      Comment


        #4
        Comparison MAX and MIN with default indicators. All inidcators set to Calculate.OnEachTick.

        The blue plot shows the version of MAX and MIN attached. The yellow plot shows the default MAX and MIN indicators that ship with NinjaTrader.

        I think that the problem is obvious.
        Attached Files

        Comment


          #5
          Originally posted by Harry View Post
          This is not a big deal. It is just a minor bug in an indicator that can be fixed in an hour. The problem here is that the logic of exotic bar types has changed and that they are processed several times when the indicator is set to Calculate.OnEachTick.

          This requires that all NinjaTrader 7 indicators are checked and adapted accordingly. For MAX and MIN this has not beend tested and therefore it cannot handle the new logic. This is an easy fix,
          Harry,

          The NT8 issue with MAX and MIN has existed for a along time.

          For example, majority of the NT7 indicators that use MAX or MIN methods in an indexing logic when converted to NT8, although they compile fine, they generate an "out of bound" error when applied to a chart.

          I am not sure if this is related to RemoveLastBar() or not. But, if that is the reason I assume Ninja using a "+1 bar" when indexing is the band-aide remedy that was not needed in NT7. Definately something is not kosher with MAX and MIN methods.

          Comment


            #6
            Originally posted by aligator View Post
            Harry,

            The NT8 issue with MAX and MIN has existed for a along time.

            For example, majority of the NT7 indicators that use MAX or MIN methods in an indexing logic when converted to NT8, although they compile fine, they generate an "out of bound" error when applied to a chart.

            I am not sure if this is related to RemoveLastBar() or not. But, if that is the reason I assume Ninja using a "+1 bar" when indexing is the band-aide remedy that was not needed in NT7. Definately something is not kosher with MAX and MIN methods.

            This is not a difficult issue. The NT8 code for MAX and MIN is just not compatible with RemoveLastBarSupported(). I have changed it and it will now work.

            The real problem is that MAX and MIN are used by a lot of system indicators. I just checked my own inventory, I have used it in 17 different indicators, all of which return false values or crash when used with Renko bars in Calculcate.OnEachTick.

            System indicators that will not work correctly on Renko bars include:

            - Aroon
            - Donchian Channel
            - Double Stochastics
            - Fisher Transform
            - Key Reversal Up
            - Key Reversal Down
            - Parabolic SAR
            - Stochastics
            - StochasticsFast
            - StochRSI
            - WilliamsR

            Together with MAX and MIN that makes up for 13 system indicators that return false values on Renko bars.

            Easy fix and as a result 12 system indicators (Aroon is a different case) would return correct values on Renko bars and Three Line Break bars.
            Last edited by Harry; 07-31-2017, 07:09 PM.

            Comment


              #7
              Hi Harry,

              Thanks for your suggestion and providing the code to demonstrate.

              I have forwarded your suggestion to the development team. I will update this post with the ticket ID when it becomes available.

              Thanks for sharing your input!
              JimNinjaTrader Customer Service

              Comment


                #8
                Some more evidence when running a Stochastics on a Renko chart:

                The chart shows a Stochastics which uses amaMAX and amaMIN (red and blue) and compares it to the system version that ships with NinjaTrader (yellow and orange).

                The system version will only show correct values on historical data. When running the indicator on real-time data, it will deviate from the correct value (see yellow dashed line). The system indicator produces correct values after a refresh via F5 only.

                Alll deviations can be attributed to the malfunction of MAX and MIN.
                Attached Files

                Comment


                  #9
                  Hi Jim,

                  This is a fat bug. Has this been confirmed by development?

                  Comment


                    #10
                    Hello Harry,

                    The ticket is currently being reviewed by the QA team. The ticket number currently is QA-3221. They will be able to officially designate the issue as a bug and I will provide a final ticket number at that time.

                    EDIT: The issue has been designated as NTEIGHT-12052 which can be found in the Release Notes help guide when a fix is implemented in a new release of NinjaTrader.

                    Thanks in advance for your patience and reporting.
                    Last edited by NinjaTrader_Jim; 08-22-2017, 09:37 AM.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      MAX, MIN working with Renko bars as expected

                      Bug is fixed with release NT 8.0.9.0.

                      MAX and MIN now working as expected.

                      Thank you again for your support.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algospoke, Today, 06:40 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post algospoke  
                      Started by maybeimnotrader, Today, 05:46 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post maybeimnotrader  
                      Started by quantismo, Today, 05:13 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post quantismo  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      8 responses
                      168 views
                      0 likes
                      Last Post jeronymite  
                      Started by cre8able, Today, 04:22 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post cre8able  
                      Working...
                      X