Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get indicator Value

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

    Get indicator Value

    Hello,

    I have my own indicator, i want to export the value of a variable ( variable declared as double ) to use it in another indicator,
    like for example for Moving average,
    we use it like this : SMA(19)[0]

    thank you in advance


    #2
    Without Plotting

    Comment


      #3
      Hello pechtri,

      Thanks for your post.

      This could be accomplished by creating a public Series<double> object which could be accessible in another indicator or strategy.

      See this help guide page detailing how to create custom Series<T> objects: https://ninjatrader.com/support/help...t8/seriest.htm

      Please see this help guide reference sample demonstrating exposing indicator values that are not plots:
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Originally posted by pechtri View Post
        I have my own indicator, i want to export the value of a variable ( variable declared as double ) to use it in another indicator,
        The easiest way to accomplish is to add a public property.

        Assuming your double variable is defined as a class level
        variable, something like this,

        Code:
        public class MyIndy : Indicator
        {
            private double myNumber;
            ...
        }
        you would add this code to the Properties section,

        Code:
        [Browsable(false)]
        [XmlIgnore]
        public double MyNumber
        {
            get { return myNumber; }
            set { myNumber = value; }
        }​
        which allows the myNumber private variable to be accessed
        from another indicator, via the MyNumber property, like this,

        MyIndy(args).MyNumber

        The XmlIgnore prevents MyNumber from being serialized and
        restored to new MyIndy indicator instances. I presumed this was
        unnecessary, since you probably calculate/assign myNumber
        internally, right? Thus, no need to save/restore it.

        The Browsable(false) attribute prevents the MyNumber property
        from being added to property grid, since presumably this is not
        user input, because you calculate/assign myNumber internally
        already -- no need to allow user input to initialize it.

        Btw, the setter is completely optional.

        Make sense?
        Last edited by bltdavid; 09-19-2023, 02:02 PM.

        Comment


          #5
          Thank you very much Guys

          Comment

          Latest Posts

          Collapse

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