Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

passing data out of an indicator

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

    passing data out of an indicator

    Platform NT 7.0.0.17

    I imagine this is more of a C# question than indicator question, but here goes....

    I have a modified version of ZigZag (renamed ZigZagNew).
    I would like to access the value of a private int...(private int trendDir.....in ZigZagNew)....from another indicator.

    So.....indicator X references ZigZagNew, and indicator X uses the value of 'trendDir' from ZigZagNew.

    It seems like I could make this some sort of "public' int.....but how would I go about doing this???

    Thanks..........

    #2
    Hi photog53,

    You will want to create a public property and be sure that Update() method is called before you return the private variable value. Update() is called to force an update to OnBarUpdate() in the event that your private variable requires the most recent indicator calculation.

    Code:
    public int TrendDir
    {
        get
        {
            Update();
            return trendDir;
        }
    }
    RayNinjaTrader Customer Service

    Comment


      #3
      Hi photog53,

      Additionally, the steps for doing so are detailed in the following sample - http://www.ninjatrader.com/support/f...ead.php?t=4991
      TimNinjaTrader Customer Service

      Comment


        #4
        Sorry for the delay in response....(I've been away from my PC).

        I don't think I quite have the concept down yet....
        Here's what I have so far....

        ----------Creating Indicator-------
        private int trendDir = 0;
        - - -
        - - -
        protected override void OnBarUpdate()

        ( logic to do something...)
        trendDir = linecount;

        Properties
        [XmlIgnore()]
        public int TrendDir
        {
        get { Update(); return trendDir; }
        }


        ----------- Calling Indicator -------------
        private int callingtrendDir;
        - - -
        - - -
        protected override void OnBarUpdate()
        (logic to do something)
        callingtrendDir = CreateIndicator(Close,14).TrendDir;


        I'm not getting the data in the 'Calling Indicator'

        Comment


          #5
          Hi photog53,

          Let's check a few things...

          1. While running the indicator, check the Log tab in the Control Center for errors.
          2. Delete the CaculateOnBarClose line from the called indicator.

          Also, as a test, try the sample code to see if that works as expected on your machine:
          http://www.ninjatrader.com/support/f...ead.php?t=4991
          TimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kazisl, Today, 06:41 PM
          0 responses
          2 views
          0 likes
          Last Post kazisl
          by kazisl
           
          Started by einstein, Today, 06:20 PM
          0 responses
          2 views
          0 likes
          Last Post einstein  
          Started by op1031, Today, 05:51 PM
          0 responses
          4 views
          0 likes
          Last Post op1031
          by op1031
           
          Started by nighttrader99, Today, 04:34 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by Simon Investimens, Today, 02:51 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X