Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use existing indicator inside custom indicator

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

    How to use existing indicator inside custom indicator

    I wish to use the ATR indicator inside my custom indicator. Note that I do NOT want to plot the ATR - I just want to use the ATR data series inside my own indicator to perform some calculations. My custom indicator will have only a single plot and the value that is plotted is computed using data from the ATR.

    I suspect I have to do several things like:
    have the proper "using" to import whatever package has the ATR
    initialize the ATR or declare it somehow
    use it in my calculations

    How do I do these? Is there an example somewhere?

    #2
    Hello westofpluto,

    Thanks for your post.

    In its simplest form you could use it directly in OnBarUpDate() like this:

    double myATRValue = ATR(14)[0]; // get the current bar 14 periodATR value

    We recommend in best practices to create a private instance of the indicator as each time it is used like above it will add an instance so if you had 6 lines like that it would add 6 instances.

    Please see the help guide example " Referencing indicator methods" here: https://ninjatrader.com/support/help...tm#Performance

    Comment


      #3
      Ok thanks, I declared a member variable "private ATR atr" and in State.DataLoaded I declared "atr = ATR(Close,14)" So far so good.

      Next question: what if I want to use my own custom indicator? For example, if I have one custom indicator called "Custom1" and my second custom indicator "Custom2" needs to use the values from Custom1. How do I load one custom indicator into another?
      Thanks.

      Comment


        #4
        Hello westofpluto,

        Thanks for your reply.

        It would be exactly the same to use any indicator.

        Create a private instance, initialize in state.Dataloaded and then access the private instance in OnBarUpdate().

        Comment

        Latest Posts

        Collapse

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