Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using a NinjaTrader indicator within a separate class

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

    Using a NinjaTrader indicator within a separate class

    When I develop indicators and strategies, I create my own classes for data analysis that can be used in both an indicator and a strategy. I want to be able to instantiate and access some of the NinjaTrader indicators within those classes but I'm having problems doing that. For example, I would like to create a new EMA or access the values from an ADX. But I'm having visibility problems to those. I'm using NinjaTrader.NinjaScript.Indicators (and all the ones used in all indicators), but that by itself doesn't work. I've tried deriving my classes from Indicator and created a default constructor, but that doesn't work either. I pass a reference to the calling indicator or strategy (like NinjaScriptBase ns and use this.ns to reach the parent) but that doesn't work either in this case. The only thing I have been able to do is create a new instance in the indicator or strategy and pass an ISeries<double> reference of it to my class to access the data but I'd rather create the instance in my own class, if possible. Can I do this and, if so, what do I need to do to get it to work?

    #2
    Hello dweems,

    A custom class wouldnt have the same context as an indicator or strategy to be able to do that. You would need to make a parameter in your classes constructor or in your method that takes the indicator you wanted to use and pass that into the class from your indicator or strategy.

    Comment


      #3
      Darn. As noted in my note I had figured that out but wanted something that didn't require me to create the instance in the main and pass it in. Thanks for confirming my worst fears and stopping me from wasting my time trying to do something that can't be done. (Ha, ha). Again, thanks for your prompt reply.

      Comment

      Latest Posts

      Collapse

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