• 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

DataSeries as an input parameter to an Indicator

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

    DataSeries as an input parameter to an Indicator

    Hi,

    I'm not sure if this is even possible, but I would like to create a sort of composite indicator where the base indicator can take other indicators as input parameters when added to a chart.

    I tried adding a DataSeries property to the indicator, but was then unable to browse to other indicators as the value.

    Is this even possible? If so, how?

    #2
    NT7 only allows a single data series as a parameterized input; this is the primary input you can select in the indicator parameters window, and you can select an indicator as the primary input. You can add additional symbols as bars objects in Initialize(), or if you know the indicators you want to use in advance you can call them in your code, but there is no way to parameterize additional indicators. In my opinion NT7 missed a major opportunity to make indicators much more useful; right now indicators-on-indicators have limited usefulness because you can only have a single indicator as input. So it's impossible,say, to make an "Add" indicator which will take 2 indicators as parameters and plot the sum of the 2. There is an "Inputs" array which I guess was planned for multiple inputs, but it currently only supports Input[[0].

    You can parameterize additional symbols (see my "Index" indicator), and another guy here has added an expression analyzer (in "UltimateIndicator") which does the kind of thing you want by building the functionality into the indicator instead of passing indicators as parameters.

    -Kevin

    Comment


      #3
      Thanks for the quick reply Kevin. Not the answer I was hoping to hear, but what I suspected. Thanks again.

      Comment


        #4
        Hello,

        This is accurate. You can change the indicators input data series inside of NinjaTrader with the data series parameter for the indicator. However you would not be able to do this in code.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Originally posted by kdoren View Post
          NT7 only allows a single data series as a parameterized input; this is the primary input you can select in the indicator parameters window, and you can select an indicator as the primary input. You can add additional symbols as bars objects in Initialize(), or if you know the indicators you want to use in advance you can call them in your code, but there is no way to parameterize additional indicators. In my opinion NT7 missed a major opportunity to make indicators much more useful; right now indicators-on-indicators have limited usefulness because you can only have a single indicator as input.
          I agree - I have a bunch of TradeStation indicators that rely on input parameters having different values on each bar. In TradeStation these inputs don't need to be series; they can be the output of some other function that is passed into the indicator, but in NinjaTrader terms this would essentially be multiple-series inputs (such as outputs from other functions). I haven't found a good way to port them over.
          -A

          Comment


            #6
            Hello,

            In code your can specify or get any output from an indicator or method.

            For example SMA is a simply example of an indicator value you are fetching and can use in your strategy.

            SMA(15);

            Outputs a 15 peroid SMA, no other setup is needed inside of code.

            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment


              #7
              Originally posted by mpugh View Post
              Hi,

              I'm not sure if this is even possible, but I would like to create a sort of composite indicator where the base indicator can take other indicators as input parameters when added to a chart.

              I tried adding a DataSeries property to the indicator, but was then unable to browse to other indicators as the value.

              Is this even possible? If so, how?
              Not a very elegant solution is to create an enum variable, with the indicators that you want to use as inputs, as the members of the enum (just the string, of course), then use a "switch" statement inside your indicator to branch to the correct code.

              The solution is of course, inelegant. You have to manually add to the enum in code, every time you want to introduce a new indicator input.

              Comment


                #8
                Originally posted by NinjaTrader_Brett View Post
                In code your can specify or get any output from an indicator or method.

                For example SMA is a simply example of an indicator value you are fetching and can use in your strategy.

                SMA(15);

                Outputs a 15 peroid SMA, no other setup is needed inside of code.
                Yes, I know that. Let me describe a problem. Within an indicator, I must calculate an indicator of an indicator. Say we call it like this within my indicator:

                val = Divg( Indicator1(period), period);

                The indicator "Divg" is a divergence indicator I wrote, intended to show divergences between any indicator and price. Divg takes as parameters an IDataSeries and an integer. But Divg also requires access to the price series High, Low, Open, Close as well as the IDataSeries output of Indicator1. The problem is that High, Low, Open, Close cannot be passed to Divg because indicators can have only one series parameter. And when Divg tries to access High, Low, Open, and Close, they are all the same value as the IDataSeries!

                Worse, it seems that on every bar Divg is called, Indicator1 is called a number of times equal to CurrentBars. This seems slow.

                The best solution is to implement my Divg indicator not as an indicator but as a public method available to several "wrapper" indicators intended to show divergences for various different oscillators. At the moment I can't figure out how, so I have Divg as a method inside the wrapper, but I don't want to have to duplicate the Divg code in each one. Is there a way to create a global method that has access to all the usual values that Indicators have access to (High, Low, Volume, etc.)?

                -A
                Last edited by anachronist; 05-28-2011, 12:22 AM.

                Comment


                  #9
                  anachronist, have you thought about adding the series you wish to have access to as well? This way you would create a MultiSeries indicator out of the Divg one that would analyze more than your one input series.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    anachronist, have you thought about adding the series you wish to have access to as well? This way you would create a MultiSeries indicator out of the Divg one that would analyze more than your one input series.
                    I'm not sure I understand what you mean. My understanding of multi-series scripts is that one is required to specify an instrument. That's fine if there's an instrument type for "whatever data series is on the chart". I prefer my indicators to work independently of the instruments.

                    My Divg indicator isn't intended to be used as a stand-alone thing. It may be better suited as a method. I'll have to study the documentation on user defined methods and the UserDefinedMethods.cs file.

                    -Alex

                    Comment


                      #11
                      Originally posted by anachronist View Post
                      Yes, I know that. Let me describe a problem. Within an indicator, I must calculate an indicator of an indicator. Say we call it like this within my indicator:

                      val = Divg( Indicator1(period), period);

                      The indicator "Divg" is a divergence indicator I wrote, intended to show divergences between any indicator and price. Divg takes as parameters an IDataSeries and an integer. But Divg also requires access to the price series High, Low, Open, Close as well as the IDataSeries output of Indicator1. The problem is that High, Low, Open, Close cannot be passed to Divg because indicators can have only one series parameter. And when Divg tries to access High, Low, Open, and Close, they are all the same value as the IDataSeries!

                      -A
                      In that case have you simply thought of exposing the OHLC values as doubles in the properties of the indicator that you want to call and access those values from?

                      Worse, it seems that on every bar Divg is called, Indicator1 is called a number of times equal to CurrentBars. This seems slow.
                      You can create an instance of the val in your OnStartUp() method, then call that instance directly in OnBarUpdate(), so that you escape the NT loop through all instances of the indicator.

                      ref: http://www.ninjatrader.com/support/f...06&postcount=7

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by nailz420, Yesterday, 08:38 AM
                      2 responses
                      11 views
                      0 likes
                      Last Post nailz420  
                      Started by bouncetherubble, Today, 06:56 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post bouncetherubble  
                      Started by James108, Today, 06:09 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post James108  
                      Started by RandanAL, Today, 05:13 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post RandanAL  
                      Started by timko, Today, 05:06 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post timko
                      by timko
                       
                      Working...
                      X