• 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 gives wrong values for underlying data series

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

    Indicator gives wrong values for underlying data series

    I am trying to convert a divergence indicator and getting incorrect results for the divergence test because Ninjatrader isn't correctly translating the values.

    The indicators are the same indicator for different versions that show the incorrect behavior. The indicators both use the RSI as the input data series. The problem in NT8 is that is gives chart values instead of RSI indicator values. The RSI is supposed to return values between 0 and 100 but that isn't what NT8 shows. Instead, it plots what looks like something similar to the RSI but with chart values. NT7 shows the values correctly.

    I attached two screen shots of an indicator with basically the same code. The first is the output when plotted in NT8 and the second is the output when plotted in NT7. The NT7 version plots correctly and the NT8 version does not.

    Click image for larger version  Name:	image_51892.png Views:	1 Size:	140.0 KB ID:	1042577

    Here is the NT7 output. As you can see, the RSI values that are output correctly. Those are not chart values in the y-axis like you see in the NT8 version.

    Click image for larger version  Name:	Indicator output NT7.png Views:	1 Size:	84.7 KB ID:	1042578

    Steps to reproduce:
    1. Load TestIndicatorV8 on an 8 range NQ chart.
    a) Before clicking OK to load the indicator, change the data series input to the RSI. It doesn't matter what parameters you use but you need to remember them so you can apply the same parameters to the real RSI chart.
    2. Load the RSI on a chart with the same parameters you used for when you loaded the RSI as the input data series for TestIndicatorV8.
    3. I put Print statements in the code so load an Output window.

    Notice the charts are very similar but not exactly the same. Also notice, the values for the RSI the indicator plots are actually the chart values, not the indicator values. The fact that the charts are not exactly the same is why the divergence indicator give incorrect results. It shows divergence when there really isn't and vice versa.

    Now do exactly the same in NT7 using the same steps to reproduce. I attached the CS files for both. Notice how the charts in the indicator panels are exactly the same. Also notice the values the indicator plots are the actual values for the RSI.

    It looks to me like Closes is returning the incorrect values for the underlying data series, which in this case is the RSI(14,3) plotted on an NQ 8-range.

    Can you suggest a way to reproduce the NT8 output just like we have in NT7?

    TestIndicatorDataV8.cs
    TestIndicatorV7.cs

    The following image shows why it's a problem:

    Click image for larger version  Name:	Screenshot 2018-12-12 12.38.25.png Views:	1 Size:	81.0 KB ID:	1042584
    Attached Files
    Last edited by traderpards; 12-12-2018, 01:11 PM.

    #2
    Hello traderpards,

    Thanks for your post.

    In NT7 when you selected an input of something other than the bar data series the input was automatically (and unintentionally) mapped to the price data series in the host indicator as specified in the indicator, thus allowing most any indicator to be used in most any other indicator despite any specifications of High, Close, Low, etc.etc in the host indicator.

    In NT8 this unintentional feature in NT7 has been rectified so when you specify a price data series (IE: Closes[0][0]) that is exactly what you get which had the unfortunate effect of causing the issue you are now investigating. An appropriate way to handle an input that is not a price data series is to use Input.

    You can easily change this in your test indicator as follows:

    Code:
             protected override void OnBarUpdate()
            {
                if( CurrentBars[0] < BarsRequiredToPlot
                    && SupportedBarsPeriodType == true ) return;
    
                if( BarsInProgress == 0 ) {
                    Print( string.Format( "Indicator bars Closes = {0}", Input[0] ) );
                }
    
                if( BarsInProgress == 1 )  {
                    Print( string.Format( "Chart bars Closes = {0}", Closes[1][0] ) );
                }
    
                DivInd[0] = Closes[0][0];
    
            }
    For further references and alternative to handle both price or an indicator as input, please see: https://ninjatrader.com/support/help...-us/?input.htm

    Click image for larger version

Name:	traderpards-1.PNG
Views:	38
Size:	101.7 KB
ID:	1042594 ​​​​​​​
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Paul - I was able to change that in the indicator I'm converting. Something still isn't right though. I'm under the impression the plot should be a mirror image of the RSI plot and it isn't. It still is messed up.

      Is there a way to make the plot the test indicator plots like like the RSI(14, 3) that I plotted separately?

      Click image for larger version

Name:	Screenshot 2018-12-12 13.59.54.png
Views:	51
Size:	86.7 KB
ID:	1042608

      Code:
      protected override void OnBarUpdate()
      {
             if( CurrentBars[0] < BarsRequiredToPlot
                    && SupportedBarsPeriodType == true ) return;
      
             if( BarsInProgress == 0 ) {
                    Print( string.Format( "Indicator bars Closes = {0}", Input[0] ) );
             }
      
             if( BarsInProgress == 1 )  {
                    Print( string.Format( "Chart bars Closes = {0}", Closes[1][0] ) );
             }
      
             DivInd[0] = Input[0];
      
      }

      Comment


        #4
        Hello traderpards,

        Thanks for your reply.

        Please try:

        if (BarsInProgress ==0)
        DivInd[0] = Input[0];
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Oh for crying out loud... I should have thought of that.

          It works though! Thank you!!!

          Comment


            #6
            Hello,

            I have a similar issue to the original poster. I am just basically trying to add to a chart an Indicator of an Indicator, and the output value I am getting for that is instead the value of the underlying symbol, ie SPY = $298.50 instead of the DonchainChannel value of the Momentum Indicator which should be something small like +/- 0.35, etc.

            On a chart Right click--> Indicators--> add DonchainChannel-->edit Data Series Input series --> select Indicators --> select Momentum --> press OK.

            Thats it...which should give me the output of the Donchain Channel value of the Momentum Indicator, basically some small number. Instead, I am getting the underlying symbol value as the output, it's totally wrong.

            Can someone help? Thanks.

            Comment


              #7
              Hello BrianL,

              Thanks for your post.

              In post#2 I clarified that in NT8 this is expected behavior of some indicators that are coded directly for price types which is the case with the Donchian Channel indicator. The Donchian Channel indicator is coded to use the High of the data series as well as the Low of the data series. You would need to modify the Donchian Channel indicator's code to accept the indicators single input value for both of those series.

              I've already done this in the indicator DonchianChannelInput (link below) that you can download, install and use in the same manner as NT7, alone or with another indicator as the input data series. When used alone, it will default to the price series. When used with another indicator as the input, it will use the inputted indicator.

              Here is a screenshot of both the regular Donchian Channel in the price panel and the DochianChannelInput with Momentum as the input series in the indicator panel.
              Click image for larger version

Name:	DonchianChannelInput.PNG
Views:	66
Size:	68.0 KB
ID:	1074684

              Here is a basic guideline of how to Import NinjaScripts.

              To import
              1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
              2. From the Control Center window select the menu File> Utilities> Import NinjaScript
              3. Select the downloaded .zip file
              4. NinjaTrader will then confirm if the import has been successful.
              Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

              DonchianChannelInput.zip
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Much appreciated PaulH for the coded indicator.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CiprianV, Today, 03:11 AM
                0 responses
                2 views
                0 likes
                Last Post CiprianV  
                Started by learningnt, Yesterday, 10:21 PM
                0 responses
                3 views
                0 likes
                Last Post learningnt  
                Started by GMiller64, Yesterday, 01:13 PM
                3 responses
                10 views
                0 likes
                Last Post GMiller64  
                Started by itrader46, Yesterday, 12:51 PM
                5 responses
                43 views
                0 likes
                Last Post rithikanth  
                Started by hemlock, Yesterday, 11:45 AM
                3 responses
                15 views
                0 likes
                Last Post NinjaTrader_PatrickG  
                Working...
                X