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

Add() question

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

    Add() question

    How do I Add() an instrument such that it has the same period type and period as the primary data series? What I want to do is to Add() an instrument such that all of its input parameters match the primary instrument.

    Is there a way to make an added instrument show up in the Data section so that the user can configure whether what Input[] will be for that data series?

    Thanks,
    EV
    Last edited by ETFVoyageur; 03-31-2014, 03:27 PM.

    #2
    Hello EV,

    Thank you for your post.

    This is possible through the BarsPeriod as seen below through Add():
    Code:
    Add("AAPL", BarsPeriod.Id, BarsPeriod.Value);
    For information on BarsPeriod please visit the following link: http://www.ninjatrader.com/support/h...barsperiod.htm

    Comment


      #3
      Patrick,

      I found that info earlier, but thought it did not apply. The BarsPeriod documentation says
      NOTE: This property should NOT be accessed within the Initialize() method.
      Is it OK to use it in Add(), which must occur in Initalize()?

      Furthermore the documentation makes it sound as if BarsPeriod is only relevant for special types

      Only relevant for Kagi, LineBreak, and PointAndFigure Bars objects.
      --EV
      Last edited by ETFVoyageur; 03-31-2014, 05:16 PM.

      Comment


        #4
        Any word on how to reconcile the NT documentation with Patrick's advice? (FWIW: I have found advice similar to Patrick's when Googling.)

        A related question: how do I set Input to be the correct series (e.g. "Typical") for an instrument I Add()?

        --EV

        Comment


          #5
          Hello EV,

          Thank you for your response.

          It is true it is listed not to call BarsPeriod inside of Initialize(), this is due to the fact that hte bars may not be loaded yet when the method is called. You can run a Try Catch on this though to ensure the bars load properly for the added instrument: http://www.ninjatrader.com/support/f...ead.php?t=9825

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello EV,

            Thank you for your response.

            It is true it is listed not to call BarsPeriod inside of Initialize(), this is due to the fact that hte bars may not be loaded yet when the method is called. You can run a Try Catch on this though to ensure the bars load properly for the added instrument: http://www.ninjatrader.com/support/f...ead.php?t=9825
            OK -- I'll look into it. Any information on my other question?
            A related question: how do I set Input to be the correct series (e.g. "Typical") for an instrument I Add()?
            Thanks,
            EV

            Comment


              #7
              Hello EV,

              Thank you for your response.

              Typical would not produce values in Initialize() as the bars would not have been loaded and therefore the (High + Low + Close) / 3 would not be attainable.

              You would need to create a custom data series in the OnBarUpdate() based on the desired values of Typicals: http://www.ninjatrader.com/support/h...7/typicals.htm

              For information on the data series class in NinjaScript please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm

              Comment


                #8
                Originally posted by NinjaTrader_PatrickH View Post
                Hello EV,

                Thank you for your response.

                Typical would not produce values in Initialize() as the bars would not have been loaded and therefore the (High + Low + Close) / 3 would not be attainable.

                You would need to create a custom data series in the OnBarUpdate() based on the desired values of Typicals: http://www.ninjatrader.com/support/h...7/typicals.htm

                For information on the data series class in NinjaScript please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm
                Sorry, but we are not communicating. I am not trying to access anything in Initialize(). I am trying to understand:
                1. If I Add() an instrument in Initialize() and then do nothing special, what will OnBarUpdate() find that Input for that instrument is linked to (OHLCMTW)? Will the linkage be controlled by how the primary instrument is linked? Will it always be to Close? Something else?
                2. How can I control what Input is linked to?

                Once again, this has nothing to do with trying to read any data or creating any data, in Initialize(). It has only to do with how to initialize an Add() instrument so that OnBarUpdate() can use Input[0] and know what to expect when it does.


                --EV

                Comment


                  #9
                  Hello EV,

                  The calls to High, Low, Open and Close are pulled from the added instrument. If you need to call these from additional bar series added to your script you would use the multiple form of each.

                  For example:
                  Please let me know if you have any questions.

                  Comment


                    #10
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello EV,

                    The calls to High, Low, Open and Close are pulled from the added instrument. If you need to call these from additional bar series added to your script you would use the multiple form of each.

                    For example:
                    Please let me know if you have any questions.
                    We are still not communicating. Once again, for an instrument I Add() in Initialize(), when the code gets to OnBarUpdate() with BarsInProgress set to the index for that instrument:
                    1. What does Input map to by default?
                    2. How an I control what Input maps to?

                    --EV

                    Comment


                      #11
                      Hello EV,

                      There is no method or way to set the input of Add() method as anything but Last, Bid or Ask. There is no option to set it to Typical for example, if you want to call Typical use the information I linked in our e-mail and on this forum thread.

                      Please review the information at the following link for using Bid, Ask or Last in Add(): http://www.ninjatrader.com/support/h...s/nt7/add3.htm

                      Comment


                        #12
                        Patrick,

                        Thanks for the effort, but we are still not communicating. One last try before I give up on this discussion.

                        * Add() an instrument in Initialize()
                        * Get to OnBarUpdate() with the the matching BarsInProgress
                        * What is "Input" mapped to?

                        --EV

                        Comment


                          #13
                          Hello EV,

                          The main bar series or the instrument the chart is applied to that you select the indicator or strategy on. As in 'Input Series' in the Indicators menu of the chart.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by bortz, 11-06-2023, 08:04 AM
                          47 responses
                          1,609 views
                          0 likes
                          Last Post aligator  
                          Started by jaybedreamin, Today, 05:56 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post jaybedreamin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          6 responses
                          19 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by Jon17, Today, 04:33 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post Jon17
                          by Jon17
                           
                          Started by Javierw.ok, Today, 04:12 PM
                          0 responses
                          16 views
                          0 likes
                          Last Post Javierw.ok  
                          Working...
                          X