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

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.
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Waxavi, Today, 02:10 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by TradeForge, Today, 02:09 AM
                        0 responses
                        10 views
                        0 likes
                        Last Post TradeForge  
                        Started by Waxavi, Today, 02:00 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by elirion, Today, 01:36 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post elirion
                        by elirion
                         
                        Started by gentlebenthebear, Today, 01:30 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post gentlebenthebear  
                        Working...
                        X