Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

C# Newbie -- How Do I Access A Custom Indicator From A New One?

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

    C# Newbie -- How Do I Access A Custom Indicator From A New One?

    I've attempted to do some homework on this, but after getting a custom indicator going, (thanks bltdavid), I'm trying to write another indicator that takes as an input the output values of the first custom indicator.

    I tried to follow the example here:

    https://ninjatrader.com/support/help...8/?addplot.htm

    But the code is for indicator values that are not plotted, so I'm not sure how to adapt it. My thinking is create a Series and then somehow assign the values from the first indicator, but I'm a bit lost on how to do this.

    If you start telling me about getter/setter and other terminology, I'm not going to understand you. Please if you can, break it down so a newbie like myself has a chance.

    I thought MAYBE it would be something like: NinjaTrader.NinjaScript.Indicators.< First custom indicator name >.< Plotted Values Name >

    But that wasn't it, or I didn't apply it correctly.
    Last edited by TallTim; 12-19-2022, 06:05 PM.

    #2
    Figured it out, finally.

    In that section where you're not supposed to change anything is where your plot series are defined for the first indicator:

    Code:
    # region Properties // From BarsWithCurrantGlaze
    
    < some other things here, possibly >
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> JuicyCurrants <-- Your ill-chosen plot name
            {
                get { return Values[0]; }
            }​
    In the second indicator, to access values from the first you can do this:

    Code:
            protected override void OnBarUpdate() // Now in another indicator
            {​
                     // Example -- double myFirstIndicatorVal = < Your first Indicator name>(< any parameters, like interval >).< plot name from region properties >[0];
    
                 double val = BarsWithCurrantGlaze(15).JuicyCurrants[0];
                Print("First Indicator value: " + val);​  // You'll see the values as the bars are processed           
            }
    Once again, it was simpler than I thought but the documentation just seems to be at times IMPENETRABLE. Maybe its C# thing, I don't know, but its damn frustrating.

    Hope it helps someone.

    Comment


      #3
      Originally posted by TallTim View Post
      Figured it out, finally.

      Once again, it was simpler than I thought but the documentation just seems to be at times IMPENETRABLE. Maybe its C# thing, I don't know, but its damn frustrating.

      Hope it helps someone.
      Yes, unfortunately the documentation isn't the best. It's very thin and unclear many times, has very few good examples and isn't exactly easy to find information in when you search it (this is probably the most frustrating). Most searches show more results for release notes than useful syntax (why would anyone put release notes in the search results for syntax?...).

      You will probably find yourself searching the forums many times and then you find the answer there instead. When I started with Ninjascript, I bought an ebook that helped me somewhat understand it better. http://ninjalaunchpad.com/. I've been coding indicators and trading scripts (java, pinescript, mql4/5, python), for other platforms, for well over a decade and Ninjascript is probably the one that I've been most frustrated with. My best advice is probably to keep up the search for good practice examples that you can keep re-using in all your indicators.

      Comment


        #4
        I promise when I find out something I'll post it under the "C# Newbie" title -- just so people understand that there's helpful info there.

        I've programmed in other languages, and shifting between them is always an exercise in forgotten syntax and all that. The documentation is detailed, but as you said, not much in the way of example for people who just want the answer to "how do I....".

        Seriously, the first thing that should be PINNED to this forum top page is my (and other) threads about how to use bar data.

        Then the logical extension to that, such as "How do I use an indicator in another."

        And then "How do I use an indicator result from another time series in a new indicator I'm building"

        Just things like that.

        Cheers!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        659 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        374 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
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X