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

Passing variable from 1 indicator to another.

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

    Passing variable from 1 indicator to another.

    Is there a way for an indicator to have access to a variable that's calculated in another indicator?

    I could always cut and paste the whole thing, but it's a little bit of a nuisance since the code to get the 1 variable that I need in another indicator is over 200 lines long and it would be nice to have it centeralized in case I need to make a change to it.

    Thank you very much.

    #2
    Hello 8DTK8,

    Yes, it's possible depending on the type of value you would like to view from this indicator. Please see this reference sample on exposing indicator values that are not plots:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      That was great. I think I'm getting it.

      I imported the sample code from Josh's post and am trying to just use the bool example. I have most of the code imbedded in a simple indicator. Now how do I access those values from another indicator? I'm having a bit of trouble finding out which lines of code are supposed to go on which side (calculating / setting the variable versus the indicator that uses the shared variable)...

      Thank you again.
      Last edited by 8DTK8; 08-20-2010, 02:21 PM.

      Comment


        #4
        There are two files in the sample.

        SampleBoolSeries is the indicator. This is where all the values are set and declared. Properties section of this file is important here.

        SampleBoolSeriesStrategy calls these values. The format for calling variables is:
        IndicatorName(IndicatorParameters).ExposedVariable
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks for all of your help Ryan.

          I'm making good progress with this but am currently casting prices into integers after multiplying them so I don't lose any details and then dividing them in the target indicator to get them back to the normal double that they are.

          Without any familiarity with using FloatSeries Class, can it carry enough details to get price levels from one indicator to another?

          Thank you.

          Comment


            #6
            I would think the FloatSeries offers enough precision for you with it's 7 digits.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks, the "7 digits" is the part that I wanted to know.

              On the same issue. Is it possible to access this FloatSeries from within the same indicator? For example, can you include the folloing code in indicator MainIndicator in order to access its value 4 bars ago?

              DrawText("name", MainIndicator().Float_Series_number[4], 0, Low[0], Color.Pink);

              Thanks again.


              Originally posted by NinjaTrader_Bertrand View Post
              I would think the FloatSeries offers enough precision for you with it's 7 digits.

              Comment


                #8
                8DTK8, this is definitely possible. Are you running into any errors/issues? You can just access the FloatSeries directly, there shouldn't be a need to use MainIndicator().FloatSeries[4]. Alternatively you could do:
                Code:
                float someFloat = this.myFloatSeries[4];
                AustinNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                53 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                33 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                5 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                19 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                6 views
                0 likes
                Last Post cre8able  
                Working...
                X