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 Lopat, 03-05-2023, 01:19 PM
          4 responses
          166 views
          0 likes
          Last Post Sam2515
          by Sam2515
           
          Started by f.saeidi, Today, 12:14 PM
          0 responses
          1 view
          0 likes
          Last Post f.saeidi  
          Started by giulyko00, Today, 12:03 PM
          0 responses
          4 views
          0 likes
          Last Post giulyko00  
          Started by AttiM, 02-14-2024, 05:20 PM
          12 responses
          213 views
          0 likes
          Last Post DrakeiJosh  
          Started by cre8able, 02-11-2023, 05:43 PM
          3 responses
          238 views
          0 likes
          Last Post rhubear
          by rhubear
           
          Working...
          X