Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Wrong values when indicator accessed from another indicator or strategy

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

    Wrong values when indicator accessed from another indicator or strategy

    I am trying to modify an indicator so that I can use its values in another indicator or strategy. I am noticing that when I use the indicator on the chart by itself, the values are correct. However when I access the same plot series from another indicator, there are ghost values present that do not come from the indicator.

    The indicator only sets -1 or 1, yet I see results like 1.23 or .87, different parameters than what my indicator is supposed to produce. Any ideas as to how to eliminate this problem?

    #2
    Hello richa61416,

    Instead of using an indicator added directly to the chart, use the Add() call in the strategy to add the indicator using the same overload parameters being called in the script.

    If the data is the same, the indicator is the same, and the parameters are the same, the plot values will be the same.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Can you post a link showing me an example of adding the indicator using the Add method, and then referencing that added indicator. I usually call the indicator when needed, but I assume that probably creates a new instance hence giving me junk data.

      thanks

      Comment


        #4
        Hi richa61416,

        There are two ways to add the indicator.

        The help guide shows calling the indicator directly:
        Add(SMA(20));

        Add() - http://ninjatrader.com/support/helpGuides/nt7/add2.htm

        But you can also save the indicator to a variable to make this easier to call. (Especially good when an indicator has a lot of parameters)

        For example:
        In #region Variables:
        private SMA mySMA;

        In Initialize():
        mySMA = SMA(14);
        Add(mySMA);

        In OnBarUpdate():
        Print(mySMA[0]);
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok. I loaded the same indicator into a strategy on the chart and still have one of the signal not showing up. Top is what it should be, the bottom is what I am seeing.
          Attached Files

          Comment


            #6
            Hello richa61416,

            The indicator being called has two plots?

            What should I be focusing on in this screenshot?

            I see that background color isn't pink in some places on the lower chart.

            The color seems to be different on the dots of one plot.

            There is a blue line on the chart above.

            However, you have multiple indicators being added to the panel on the top. I wouldn't be able to tell what is what. Please remove all indicators except for the one being called by the strategy.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Yea. They are all part of the same indicator. What is missing is the PINK signal. If you notice the top one that is added using add indicator contains the pink. The lower one without the pink is the one added using the strategy. The inputs are visible and is the same. The Pink and blue plots is the same plot series, however the negative sign one if not showing. Even tried making it positive by still nothing.

              Comment


                #8
                Hello richa61416,

                May I test the script on my end to see if I get the same results?

                To export a NinjaTrader 7 NinjaScript do the following:
                1. Click File -> Utilities -> Export NinjaScript
                2. Enter a unique name for the file in the value for 'File name:'
                3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
                4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


                By default your exported file will be in the following location:
                • (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript\<export_file_name.z ip>


                Below is a link to the help guide on Exporting NinjaScripts.
                http://www.ninjatrader.com/support/h...nt7/export.htm

                Once exported, please attach the export to your next post.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Sure. Here it is. From the screen shot please note that I am using FisherTransform to feed the input series.
                  Attached Files

                  Comment


                    #10
                    Hello richa61416,

                    Your export did not contain a strategy to test, it only contained the indicator.

                    As a convenience to you I have created a strategy on your behalf to test adding the indicator to the chart with the Add() call and then comparing the values from the output of the strategy to the values shown on the chart.

                    Below is a link to a video I created to show that while testing this, all values on the chart matched the values printed by the strategy.
                    http://screencast.com/t/vl2TSd2E

                    And attached is an export of the script I made to test this indicator. (Besure to add this to a blank chart that does not have any indicators on it.)
                    Attached Files
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by egordleo, Today, 05:50 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post egordleo  
                    Started by kevinenergy, 02-17-2023, 12:42 PM
                    118 responses
                    2,778 views
                    1 like
                    Last Post kevinenergy  
                    Started by briansaul, Today, 05:31 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post briansaul  
                    Started by fwendolynlpxz, Today, 05:19 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post fwendolynlpxz  
                    Started by traderqz, Yesterday, 12:06 AM
                    11 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X