Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question on Referencing another Indicator

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

    Question on Referencing another Indicator

    Indicator A which is installed on a chart defines globally and populates a DataSeries whether it be plot or something else.

    Indicator B would like to use that DataSeries.

    Indicator B can define an instance of Indicator A and access that DataSeries but then we have Two instances of indicator A running.

    Is there another method for Indicator B to access that DataSeries directly from the already running version of Indicator A ?

    Thanks for any input.

    #2
    Hello JerryWar,

    Thank you for your post.

    Indicator's would not be able to access other indicator's instances. However, in a strategy when adding the indicators you can create instantiated indicators and then plot those and access their values.

    For example:
    Code:
            private SMA sma1;
    		private SMA sma2;
    		
            protected override void Initialize()
            {
    			sma1 = SMA(10);
    			sma2 = SMA(20);
    			Add(sma1);
    			Add(sma2);
            }
    Keep in mind this would only work in a strategy.

    Please let me know if you have any questions.

    Comment


      #3
      Patrick
      Thanks - That is pretty clear. In this situation , I don't think a strategy is going to get it done.
      I do have one follow up question. Inside an indicator when I add a higher level time frame.
      Is there anyway to specify a longer barsback period than the barsback set for the root data series. I am trying to conserve resources. If I extend the root data barsback it will tie up too many resources. What I need is for the higher time frame dataseries added in the indicator to
      have a longer barsback period but I do not see an overload which will accept that in the Add().

      Comment


        #4
        Originally posted by JerryWar View Post
        Patrick
        Thanks - That is pretty clear. In this situation , I don't think a strategy is going to get it done.
        I do have one follow up question. Inside an indicator when I add a higher level time frame.
        Is there anyway to specify a longer barsback period than the barsback set for the root data series. I am trying to conserve resources. If I extend the root data barsback it will tie up too many resources. What I need is for the higher time frame dataseries added in the indicator to
        have a longer barsback period but I do not see an overload which will accept that in the Add().
        Thank you for your response.

        There would not be a means to set the bars back of the secondary series in NinjaTrader 7. In NinjaTrader 8 you can use the barsToLoad overload: http://ninjatrader.com/support/helpG...dataseries.htm

        Please let me know if you have any questions.

        Comment


          #5
          Patrick,
          You just made me realize the obvious. All I need do is delay the start of the computations on the root
          series and that should eliminate my issue. I also gave more thought to what you said about a strategy and possibly there is a way that can be useful but it requires splitting apart a complex indicator and I had always envisioned going the other way i.e. having my indicator feed my Strategy.

          thanks again.
          Jerry

          Comment


            #6
            Patrick,
            I want to set the start date/time of my calculations x days back on the root Tick data series. So rather than checking for

            " if (CurrentBars[0] < BarsRequired ) return " I want to do something like

            if ( Current Day < ( Today(Time[0]) - 2 days) ) return

            But I am having trouble with subtraction part because I want to only consider Weekday, trading days excluding holidays. Is there a function that uses the session template that will allow me to calculate this simply. If you have any links or examples that would be great.

            Jerry

            Comment


              #7
              Hello JerryWar,

              Thank you for your post.

              The Session information could be pulled for this purpose: http://ninjatrader.com/support/helpG...t7/session.htm

              Please let me know if you have any questions.

              Comment


                #8
                I seem to be having a fundamental problem in determining Current Day - 2 days regardless of session template. The issue is that I cannot figure out how to get the current Day. I can get the day of any bar
                using Today(Time[0]) but I need to know the current day before the indicator winds up to be able to know when to start calculating. Of course I could use the computer Date but then it will not work on Replay data. How do I do this?

                thanks

                Comment


                  #9
                  Hello JerryWar,

                  Thank you for your patience.

                  You could pull Time[0].Date or Time[0].Day, whichever you need. Information on what can be pulled from the DateTime object Time can be found at the following link: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

                  Please let me know if you have any questions.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by michi08, 10-05-2018, 09:31 AM
                  2 responses
                  739 views
                  0 likes
                  Last Post Denver_Wayne  
                  Started by sightcareclickhere, Today, 01:55 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post sightcareclickhere  
                  Started by Mindset, 05-06-2023, 09:03 PM
                  9 responses
                  258 views
                  0 likes
                  Last Post ender_wiggum  
                  Started by Mizzouman1, Today, 07:35 AM
                  4 responses
                  18 views
                  0 likes
                  Last Post Mizzouman1  
                  Started by philmg, Today, 01:17 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Working...
                  X