Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

access data from another indicator?

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

    access data from another indicator?

    I want to run 4 versions of an indicator from 1 script.

    Each version will have a different setting, and the script will make changes to it,

    How do I set the script upto to send the input numbers to indicator in the script.

    And more importantly how do I bring back more than 1 number that I want?

    Tinkerz

    #2
    tinkerz, by "script" do you mean strategy?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Both strategy and indicator

      Comment


        #4
        Thank you for the clarification. You can assign indicators to variables to help you keep track of what indicator uses what settings. Here is an example with an ATR indicator:
        Code:
        // in variables section
        ATR myATRFive;
        
        Initialize()
        {
        myATRFive = ATR(5);
        }
        
        OnBarUpdate()
        {
           if (myATRFive[0] > 1000000)
            /// strong trend
        }
        AustinNinjaTrader Customer Service

        Comment


          #5
          So is there a way of taking more than one output from the indicator?

          And the output for ATR(5), is what is assigned to plot 1?

          Comment


            #6
            If you look at the code generated by the wizard when you have multiple plots in one indicator, then you will see how NT exposes internal variables for external reference.
            You can do the same thing with any internal variable. It looks just like the input code (in the region called Properties) except there is no set statement. Don't forget the [] code every time - just consider it required before every public code statement.
            [Browsable(false)]
            [XmlIgnore()]


            then you can reference the external variable with code like:
            MyIndicator(inputVar, inputVar).OutputVar

            Take a look at other code samples and you will get the idea.

            Comment


              #7
              Thanks I will take a look.

              Even with that code it looks like it will setup 1 indicator per variable.

              So how would you then initialize one indicator to return multiple outs?

              Too run less overhead, would you be setting up namespaces?

              Or can you assign the indicator to class or something?

              Because I will probably have 1 version of the indicator with different input settings but wanting to collect for that 1 data reference from it.

              So therefore I want to minimize the CPU overhead, and make sure the same indicator with different settings is not interfering with each other

              Comment


                #8
                Think about what you want. If you want multiple plots on the chart, just add multiple plot statements. One indicator can easily have several outputs to a chart, several input variables, and likewise several output variables. Just name them differently. Out1, Out2, etc.

                Comment


                  #9
                  Ok, I did not explain myself properly

                  data1=MyIndicator(inputVar, inputVar).OutputVar

                  I assume you initialize the variable in the initialize section.

                  Wont that mean if I do this

                  data1=MyIndicator(256, 256).OutputVar
                  data2=MyIndicator(256, 256).OutputVar2

                  That I am running 2 versions of the same indicator.

                  Where I only need to do one?

                  If I can set my output to an array type, then I only need to initialize one indicator saving cpu time and memory?





                  Comment


                    #10
                    Ah, you are asking about Ninjatrader intelligence in optimization of code...
                    Can't help you there, sorry.

                    Comment


                      #11
                      tinkerz, I will have someone get back to you tomorrow.
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        tinkerz, indicator instances would be cached by NT internally if you call the indicator with the same parameters as in your example case.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        571 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        330 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        549 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        549 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X