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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    150 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X