Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reading from an Indicator

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

    Reading from an Indicator

    This one has me stumped.
    I created an indicator for use inside a strategy. The indicator is called STOCheck. I have three public vars on it that I would like to read out. I added it to a chart (see attached JPG), and I am printing out the values on the chart to make sure there are no errors. In this case, the values returned are TRUE, TRUE, and 3.
    However, in my strategy, at this very point in time, when I call my indicator, it always returns FALSE, FALSE, and 0. There are no errors in the log, and the strategy runs fine. I have other indicators that return values using this same technique, so I know I am not crazy. I have verified every single argument call and they match what is on the chart perfectly. I have recompiled everything numerous times.
    The only thing I can think of is that this is a multi-bar strategy. My first (default) bars are at 10 ticks. I am evaluating this indicator on the second set of bars (1 minute) which match the chart. However, I have about 5 other indicators using the same technique which return data just fine.
    I can’t figure out for the life of me how to debug this other than printing to the Output window from the strategy. I have been working on this for a while and I finally give up. What could be going on here? I am obviously missing something.
    Thanks!
    Michael
    Attached Files

    #2
    Hi Michael, have you seen the reference sample titled: Exposing indicator values that are not plots?

    The best way to get variables from another indicator is to expose them in properties, not by making the variables public. That way you can ensure they're up to date and accurate.

    In this thread, I've explained how the indicator and the strategy in the first link work together.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Public Properties

      Sorry, I worded that wrong -- they are public properties on my indicator. Obviously they are getting the defaults (FALSE, 0.) Internally, I am printing out on the chart what is contained in the Public Property, so I know they are getting populated. I assume that both my chart and the strategy reference the same instance, correct? There seems to be some issue referencing this indicator; almost like it is stuck in cache or memory somewhere.

      Comment


        #4
        Michael, I don't know if you looked at the reference sample I linked to you, but the public properties have a specific Update() to keep everything accurate.
        Code:
        [Browsable(false)]
        [XmlIgnore()]
        public double ExposedVariable
        {
        // We need to call the Update() method to ensure our exposed variable is in up-to-date.
                get { Update(); return exposedVariable; }
        }
        If you include the above code, the variable will be refreshed, so it won't be stuck in memory or cache or anything.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Thanks!

          Using Update() works. That appears to be the problem...

          Comment


            #6
            ?

            Shouldn't you guys add this code to every property created by the wizard? Or is that a performance hog??

            Comment


              #7
              Should not be in every property since most properties uses are not to expose internal variables of the indicator but to allow customization of parameters for the indicator.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                ?

                Right, but it sure would be nice on the wizard to mark which variables are "out" variables and add the code.

                Comment


                  #9
                  moflaherty,

                  You need to custom program to do that and not do it from the Wizard. The Wizard is designed to get the majority of people moving forward. For very specific use cases like yours you just need to custom program it. Thank you for the suggestion though.
                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

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