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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    44 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    58 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    35 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    95 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    59 views
    0 likes
    Last Post PaulMohn  
    Working...
    X