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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        80 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X