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

(NT7) Indicator on indicator AND price

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

    (NT7) Indicator on indicator AND price

    Hi,

    I'd like to make an indicator, reading another indicator, so in input series you can set the second indicator to read data from.

    My question: what is the best method with this setup to be able to reach the chart's price data as well?
    Do I need to add it as a secondary dataseries?

    #2
    Hello,

    Thank you for the question.

    It is possible to use an indicator as input for another indicator. Can you tell me, is the indicator you want to read one of the standard items that comes with the platform? Likely I could provide a simple example of calling an indicator from a indicator if you can provide a few more details on the specifics.

    In general there is no problem calling an indicator from another indicator, no additional data series would be required to do that unless you wanted to pass a series that is not the Primary series to that indicator. In that case some additional steps would be needed.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,

      I want the secondary indicator to be selected. Thus I need to use the indicator menu's "input series" - this way nesting the secondary indicator to the primary one.

      In this case however all the Close, High, etc will be the primary dataseries' values, which is the nested indicator.

      My question is this:
      what is the best method to be able to select any indicator as an input for a script AND be able to reach price data from within a script.

      Comment


        #4
        Hello,

        I wanted to make sure I understand what you are saying.

        Do you mean that you want a drop down box in IndicatorA that shows IndicatorB along with other selections of other indicators?

        If so, generally you would need to create an enum with the items you want in the list, and use Logic in OnBarUpdate to delegate what indicator is returning data.

        Can you confirm if I have understood the description correctly?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I meant this. IMHO this is the easiest way to feed a nested indicator.
          My problem is that if I go on this route, all the price info is "lost", since we don't have the price as input, but another indicator.

          So the question: what do you think the easiest way to be able to reach BOTH the nested indi value AND the price?

          My solution: add nested indi as input (as in the image), and add the price as a secondary dataseries in the Initialize method.
          Add(Instrument.FullName,BarsPeriods[0].Value, BarsPeriods[0].Id);
          It works, however it unneccesseraly complicates things.

          Comment


            #6
            Hello,

            Yes if you are specifically providing the Input as another indicator, it would use that data instead of the Price data.

            What I mentioned in the prior post would likely be one solution. Rather than using the Input picker, you could make your own input to pick what indicators you want to use.

            Once you select a indicator, you could use a switch statement or set of if statements to check different indicators. The Primary price data would still be incoming as you are not using the user interface to specifically pick indicator as the input.

            I will provide a very basic example using a int, you could change this to make it more functional this would only be to demonstrate a concept.

            Code:
            int myIndicator = 0;
            [Description("Numbers of bars used for calculations")]
            [GridCategory("Parameters")]
            public int MyIndicator   
            {
            	get { return myIndicator ; }
            	set { myIndicator =value; }
            }
            
            double myIndicatorValue = 0;
            
            if(MyIndicator   == 0)
            {
               myIndicatorValue = SMA(12)[0];
            } 
            else
            if(MyIndicator  == 1)
            {
               myIndicatorValue = EMA(12)[0];
            }

            While there is some additional syntax needed, this would allow you to pick a Indicator input, while maintaining the price data. If you do not want to go that route, you could instead do as you had mentioned and add a secondary series as well.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jon17, Today, 04:33 PM
            0 responses
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            4 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Started by alifarahani, Today, 09:40 AM
            6 responses
            40 views
            0 likes
            Last Post alifarahani  
            Started by Waxavi, Today, 02:10 AM
            1 response
            19 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Working...
            X