Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to add own class

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

    How to add own class

    Hello Ninja Scripters,

    I guess, this should be a simple questions for most of you guys, yet find no answer to this.
    I hope someone out there might help me and give me a short answer. I'd be quite thankful.

    I want to create a custom Indicator. Yet, when I create my own Class under the namespace:
    NinjaTrader.NinjaScript.Indicators .... why can't I use the piece of Information like the: Bars.GetHigh?

    the "Using" includes the: NinjaTrader.Data ... which, I thought, gives access to the Bars information, yet why can't I enter this Bars information?
    The Ninja Script Help Guide says that you can't just use, for example, "High[2]" out of the OnBarUpdate-EventHandler, you need to use the Bars.GetHigh() Method,
    but it doesn't work. So How can I access the Bars Data Information when using my own class?



    #2
    Welcome to the forums Sebastian Leitner!

    Bars is provided from the indicator base class.

    If you want to access Bars (or other properties from the host class) from a custom class, I suggest creating a NinjaScriptBase parameter for your class's constructor so you can access properties from within your custom class.

    Please see the attached example.

    Let us know if you have any questions.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    650 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    370 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    574 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    577 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X