Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:
          TimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rocketman7, Today, 02:12 AM
          6 responses
          26 views
          0 likes
          Last Post rocketman7  
          Started by guillembm, Yesterday, 11:25 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by junkone, 04-21-2024, 07:17 AM
          10 responses
          148 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by tsantospinto, 04-12-2024, 07:04 PM
          6 responses
          101 views
          0 likes
          Last Post tsantospinto  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          7 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X