Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IndicatorBase objects

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

    IndicatorBase objects

    Here I go again poking around where I shouldn't.

    When you call Add() in Initialize() in a strategy, I typically saw it written as :
    Add(SMA(10));

    But the compiler shows it's looking for an IndicatorBase object. So just for fun I went:

    private IndicatorBase mySMA = null;

    mySMA = SMA(10);
    Add(mySMA);
    mySMA.Plots[0].Pen.Color = Color.Orange;

    And wow, everything worked. Then I went to look in the docs and did a search for IndicatorBase and NOTHING CAME UP!

    I'm very new at all of this - does this mean this is a new class? Or just something as an end user we shouldn't mess with? I'm trying to learn HOW to learn Ninjascript, and finding an important class NOT in the docs scares me.

    Ok, just wondering. I thought making an object reference for the indicator would be better than calling (or typing out) full indicators everytime you need to work with one. Maybe there is no speed difference at all and I just wasted everyone's time who read this, haha.

    #2
    Hello Locke,

    Thank you for your post.

    This would just be considered unsupported code.

    Comment


      #3
      Originally posted by Locke View Post
      Here I go again poking around where I shouldn't.

      When you call Add() in Initialize() in a strategy, I typically saw it written as :
      Add(SMA(10));

      But the compiler shows it's looking for an IndicatorBase object. So just for fun I went:

      private IndicatorBase mySMA = null;

      mySMA = SMA(10);
      Add(mySMA);
      mySMA.Plots[0].Pen.Color = Color.Orange;

      And wow, everything worked. Then I went to look in the docs and did a search for IndicatorBase and NOTHING CAME UP!

      I'm very new at all of this - does this mean this is a new class? Or just something as an end user we shouldn't mess with? I'm trying to learn HOW to learn Ninjascript, and finding an important class NOT in the docs scares me.

      Ok, just wondering. I thought making an object reference for the indicator would be better than calling (or typing out) full indicators everytime you need to work with one. Maybe there is no speed difference at all and I just wasted everyone's time who read this, haha.
      It is not documented because it is a base class: specifically the base class from which the Indicator class inherits. There are certain advantages to what you have written, but using such code would still fall in unsupported territory. You just have to remain aware of it.

      Comment

      Latest Posts

      Collapse

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