Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7: Referencing an indicator from another indicator

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

    NT7: Referencing an indicator from another indicator

    Greetings

    I searched the message archives to see if this problem has been discussed before and it seems it has not.

    It appears that if an indicator (indicator B) is referenced from another indicator (indicator A), any calls to High[Bar], Low[Bar], Close[Bar], Open[Bar] and Volume[Bar] in indicator B will result in 0 being returned as the value. To further illustrate this point, consider this psuedo example:

    class IndicatorB
    {
    public double GetIndicatorValue()
    {

    double h = High[0];
    double l = Low[0];

    //perform some calculation and assign value to X

    return X;

    }

    protected override void OnBarUpdate()
    {
    double x = GetIndicatorValue();

    //plot it
    }
    }

    When IndicatorB().GetIndicatorValue() is called from another indicator(IndicatorA), the returned value is always zero simply because High[0] and Low[0] are 0.

    IndicatorB works as expected if it is inserted on a chart.

    Both indicators were developed in NT6.5 and imported to NT7. This means that in NT6.5, IndicatorB is referenced from IndicatorA and it works as expected.

    What changed in NT7 that is causing this problem?

    Can one of NT folks provide a guideline as to how reference and use indicators from other indicators in NT7?

    Thanks in advance.
    Last edited by svrz; 04-24-2010, 11:27 PM.

    #2
    As I step through the code via the debugger, it appears that the Open, High, Low and Close values of the IndicatorB get intialized via the IndicatorBase class:

    indicator.Input = input;

    However when the Volume[0] is called in IndicatorB via IndicatorA, the exception "Object reference not set to an instance of an object" is thrown. No such problems are seen in NT6.5.

    This is very puzzling as it appears something fundamental has changed in NT7. However I don't see any references in "NT7 Code Break" document that explains this.

    Please advise!

    Comment


      #3
      I'm not sure of the exact cause of your problem, but I suspect that merely referencing a public function inside another indicator is not enough to get it properly instantiated and updating in NT7. NT7 allows multi-timeframe and multi-instrument indicators, so I think each indicator is instantiated in its own space.


      Instead of referencing "IndicatorB().GetIndicatorValue()", try using "IndicatorB()[0]" and see if that helps.

      Comment


        #4
        Thank you for the reply, kdroen. It looks like I have to rework many of these indicators for NT7.

        It would be quite useful if one of the NT folks can chime in and let us know how indicators in NT7 sink with the basic OHLC and volume data in addition to how this procedure is different from NT6.5.

        Comment


          #5
          svrz,

          It is not exactly clear to me what issue you are facing exactly. Can you please provide a simple as possible sample as to what you are facing? Thank you.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thanks for the reply, Josh.

            I went back to the archives and followed the procedure outlined in SampleBoolSeries. Everything is fine now.

            Take care

            Comment

            Latest Posts

            Collapse

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