Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need Help with Exposing Indicator Values

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

    Need Help with Exposing Indicator Values

    Hi, I have a simple sender indicator that exposes its values and a receiver indicator that reads the value:

    Sender indicator:
    PHP Code:
    
    public class mySender : Indicator
        {
            private Series<double> MySeries;
            private double         exposedVariable;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                   .
                   .
                   .
                    
                    AddPlot(new Stroke(Brushes.Cyan, 3), PlotStyle.Line, "MyLine");
                    MySeries             = new Series<double>(this);
                    //MyBool            = false;
    
            protected override void OnBarUpdate()
            {
                if (CurrentBar < 2)
                {
                    return;
                }
    
                MySeries[0]     = (Open[0] + Close[0])/2;
                MyLine[0]       = SMA(MySeries,10)[0];
                
                exposedVariable = MyLine[0];
                
            }
    
            public double ExposedVariable
            {
                get { Update(); return exposedVariable; }
            }
            
            #region Properties
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> MyLine
            {
                get { return Values[0]; }
            }
    
            /*
            [NinjaScriptProperty]
            [Display(Name = "My Bool", Order = 1, GroupName = "Settings")]
            [XmlIgnore]
            public bool MyBool
            { get; set; }
            */
    &#8203;
            #endregion​ 
    

    Receiver Indicator:
    PHP Code:
    protected override void OnBarUpdate()
    {
           Print(mySender().ExposedVariable);
    }&#8203; 
    

    Both indicators are working fine. However, when I removed the comments to add MyBool into the code, I get the error from the receiver indicator:
    No overload for method 'mySender' takes 0 arguments

    I would appreciate assistance to explain what went wrong and what I can do to make it run correctly.

    Last edited by Rainmakersg; 10-01-2024, 02:30 AM.

    #2
    Hi Rainmakersg,

    After you add the MyBool property to the mySender indicator, you can pass a true/false value to the mySender() function when calling it.

    Please refer to the code below:

    Code:
    protected override void OnBarUpdate() {
        Print(mySender(true).ExposedVariable);
    }
    Regards,
    William
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #3
      Originally posted by ninZa View Post
      Hi Rainmakersg,

      After you add the MyBool property to the mySender indicator, you can pass a true/false value to the mySender() function when calling it.

      Please refer to the code below:

      Code:
      protected override void OnBarUpdate() {
      Print(mySender(true).ExposedVariable);
      }
      Regards,
      William
      Hi Williams,

      Thanks for the reply. The problem is I cannot even add the MyBool property as the error will show up. MyBool is for other purposes and not related to sender sending out the exposed value.

      Comment


        #4
        Hello Rainmakersg,

        Below is a link to the reference sample on exposing properties that are not series.


        From the example:

        Code:
        private double exposedVariable;
        
        public double ExposedVariable
        {
        // We need to call the Update() method to ensure our exposed variable is in up-to-date.
        get { Update(); return exposedVariable; }
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by ninZa View Post
          Hi Rainmakersg,

          After you add the MyBool property to the mySender indicator, you can pass a true/false value to the mySender() function when calling it.

          Please refer to the code below:

          Code:
          protected override void OnBarUpdate() {
          Print(mySender(true).ExposedVariable);
          }
          Regards,
          William
          Hi William, I finally understood what you typed. Thanks so much for your assistance.

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello Rainmakersg,

            Below is a link to the reference sample on exposing properties that are not series.


            From the example:

            Code:
            private double exposedVariable;
            
            public double ExposedVariable
            {
            // We need to call the Update() method to ensure our exposed variable is in up-to-date.
            get { Update(); return exposedVariable; }
            }
            Thanks Chelsea.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            605 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            351 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
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            561 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X